| 1234567891011121314151617181920212223242526272829303132333435 |
- import { computed, ref } from 'vue';
- export default (function (stretch) {
- var targetSize = ref({
- width: 0,
- height: 0
- });
- function measureStretch(element) {
- targetSize.value = {
- width: element.offsetWidth,
- height: element.offsetHeight
- };
- }
- // Merge stretch style
- var style = computed(function () {
- var sizeStyle = {};
- if (stretch.value) {
- var _targetSize$value = targetSize.value,
- width = _targetSize$value.width,
- height = _targetSize$value.height;
- // Stretch with target
- if (stretch.value.indexOf('height') !== -1 && height) {
- sizeStyle.height = "".concat(height, "px");
- } else if (stretch.value.indexOf('minHeight') !== -1 && height) {
- sizeStyle.minHeight = "".concat(height, "px");
- }
- if (stretch.value.indexOf('width') !== -1 && width) {
- sizeStyle.width = "".concat(width, "px");
- } else if (stretch.value.indexOf('minWidth') !== -1 && width) {
- sizeStyle.minWidth = "".concat(width, "px");
- }
- }
- return sizeStyle;
- });
- return [style, measureStretch];
- });
|