useStretchStyle.js 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", {
  3. value: true
  4. });
  5. exports.default = void 0;
  6. var _vue = require("vue");
  7. var _default = function _default(stretch) {
  8. var targetSize = (0, _vue.ref)({
  9. width: 0,
  10. height: 0
  11. });
  12. function measureStretch(element) {
  13. targetSize.value = {
  14. width: element.offsetWidth,
  15. height: element.offsetHeight
  16. };
  17. }
  18. // Merge stretch style
  19. var style = (0, _vue.computed)(function () {
  20. var sizeStyle = {};
  21. if (stretch.value) {
  22. var _targetSize$value = targetSize.value,
  23. width = _targetSize$value.width,
  24. height = _targetSize$value.height;
  25. // Stretch with target
  26. if (stretch.value.indexOf('height') !== -1 && height) {
  27. sizeStyle.height = "".concat(height, "px");
  28. } else if (stretch.value.indexOf('minHeight') !== -1 && height) {
  29. sizeStyle.minHeight = "".concat(height, "px");
  30. }
  31. if (stretch.value.indexOf('width') !== -1 && width) {
  32. sizeStyle.width = "".concat(width, "px");
  33. } else if (stretch.value.indexOf('minWidth') !== -1 && width) {
  34. sizeStyle.minWidth = "".concat(width, "px");
  35. }
  36. }
  37. return sizeStyle;
  38. });
  39. return [style, measureStretch];
  40. };
  41. exports.default = _default;