@fonixtree/magic-design 2.0.29 → 2.0.31

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -100,9 +100,11 @@ function (_super) {
100
100
 
101
101
  this.intersectionObserver = new IntersectionObserver(function (entries) {
102
102
  if (entries[0].isIntersecting) {
103
- _this.setState({
104
- show: true
105
- });
103
+ if (!_this.state.show) {
104
+ _this.setState({
105
+ show: true
106
+ });
107
+ }
106
108
  }
107
109
  }, {
108
110
  root: (_a = this.props) === null || _a === void 0 ? void 0 : _a.rootContainer(),
@@ -120,14 +122,13 @@ function (_super) {
120
122
  var _this = this;
121
123
 
122
124
  var _a = this.props,
123
- root = _a.root,
124
125
  _b = _a.lazy,
125
126
  lazy = _b === void 0 ? true : _b,
126
127
  src = _a.src,
127
128
  onLoadFunc = _a.onLoadFunc,
128
129
  style = _a.style,
129
130
  className = _a.className,
130
- rest = __rest(_a, ["root", "lazy", "src", "onLoadFunc", "style", "className"]);
131
+ rest = __rest(_a, ["lazy", "src", "onLoadFunc", "style", "className"]);
131
132
 
132
133
  var show = this.state.show;
133
134
  var isShow = lazy ? show : true;
@@ -15,6 +15,8 @@ var _defaultJSON = require("./defaultJSON");
15
15
 
16
16
  var _compositeDecorator = _interopRequireDefault(require("../../../../decorator/compositeDecorator"));
17
17
 
18
+ var _decorator = require("../../../../decorator");
19
+
18
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
21
 
20
22
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -65,21 +67,43 @@ function (_super) {
65
67
  __extends(Carousel, _super);
66
68
 
67
69
  function Carousel() {
68
- return _super !== null && _super.apply(this, arguments) || this;
70
+ var _this = _super !== null && _super.apply(this, arguments) || this;
71
+
72
+ _this.state = {
73
+ lazyShow: false
74
+ };
75
+ _this.carouselRef = /*#__PURE__*/_react["default"].createRef();
76
+ _this.intersectionObserver = null;
77
+ return _this;
69
78
  }
70
79
 
80
+ Carousel.prototype.componentDidMount = function () {};
81
+
82
+ Carousel.prototype.componentWillUnmount = function () {};
83
+
71
84
  Carousel.prototype.render = function () {
72
85
  var nodeData = this.props.nodeData;
73
- return /*#__PURE__*/_react["default"].createElement("div", null, window.magicDesign.device === 'pc' ? /*#__PURE__*/_react["default"].createElement(_pc["default"], {
86
+ var lazyShow = this.state.lazyShow;
87
+ return /*#__PURE__*/_react["default"].createElement("div", {
88
+ ref: this.carouselRef,
89
+ style: {
90
+ height: lazyShow ? 'auto' : 300
91
+ }
92
+ }, lazyShow && (window.magicDesign.device === 'pc' ? /*#__PURE__*/_react["default"].createElement(_pc["default"], {
74
93
  data: nodeData
75
94
  }) : /*#__PURE__*/_react["default"].createElement(_mobile["default"], {
76
95
  data: nodeData
77
- }));
96
+ })));
78
97
  };
79
98
 
80
99
  Carousel.defaultProps = {};
81
100
  Carousel.type = 'CAROUSEL';
82
101
  Carousel.getDefaultJSON = _defaultJSON.getDefaultJSON;
102
+
103
+ __decorate([(0, _decorator.lazy)('carouselRef')], Carousel.prototype, "componentDidMount", null);
104
+
105
+ __decorate([_decorator.lazyDestroy], Carousel.prototype, "componentWillUnmount", null);
106
+
83
107
  Carousel = __decorate([_compositeDecorator["default"]], Carousel);
84
108
  return Carousel;
85
109
  }(_react.Component);
@@ -73,24 +73,13 @@ var __assign = void 0 && (void 0).__assign || function () {
73
73
  return __assign.apply(this, arguments);
74
74
  };
75
75
 
76
- var MOBILE_IMG_SIZE = {
77
- 1: {
78
- maxH: 282
79
- },
80
- 2: {
81
- maxH: 137
82
- },
83
- 3: {
84
- maxH: 87
85
- },
86
- 4: {
87
- maxH: 66
88
- },
89
- 5: {
90
- maxH: 50
91
- }
92
- };
93
-
76
+ // const MOBILE_IMG_SIZE = {
77
+ // 1: { maxH: 282 },
78
+ // 2: { maxH: 137 },
79
+ // 3: { maxH: 87 },
80
+ // 4: { maxH: 66 },
81
+ // 5: { maxH: 50 },
82
+ // };
94
83
  var CarouselMobile =
95
84
  /** @class */
96
85
  function (_super) {
@@ -247,7 +236,8 @@ function (_super) {
247
236
  GAData: __assign(__assign({}, GAData), {
248
237
  groupId: item.id,
249
238
  groupName: (0, _ConfigPanel.getSecondConfigName)(data, item.id)
250
- })
239
+ }),
240
+ notNeedLazy: true
251
241
  })), layout === 'layout2' && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, item.title.open && /*#__PURE__*/_react["default"].createElement("div", {
252
242
  className: "title"
253
243
  }, /*#__PURE__*/_react["default"].createElement(_components.MetaText, {
@@ -272,7 +262,8 @@ function (_super) {
272
262
  groupId: item.id,
273
263
  groupName: (0, _ConfigPanel.getSecondConfigName)(data, item.id)
274
264
  }),
275
- maxHeight: 20
265
+ maxHeight: 20,
266
+ notNeedLazy: true
276
267
  }), item.buttonTag.open && /*#__PURE__*/_react["default"].createElement(_components.MetaButton, {
277
268
  data: item.buttonTag,
278
269
  GAData: __assign(__assign({}, GAData), {
@@ -280,7 +280,8 @@ function (_super) {
280
280
  }),
281
281
  maxHeight: item.image.content.pcImgSrc ? 'unset' : PC_IMG_SIZE[floorColNum].defH,
282
282
  minHeight: PC_IMG_SIZE[floorColNum].minH,
283
- minWidth: PC_IMG_SIZE[floorColNum].minW
283
+ minWidth: PC_IMG_SIZE[floorColNum].minW,
284
+ notNeedLazy: true
284
285
  })), layout === 'layout2' && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, item.title.open && !((0, _coreUtil.isPc)() && item.title.pcText === '') && /*#__PURE__*/_react["default"].createElement("div", {
285
286
  className: "title"
286
287
  }, /*#__PURE__*/_react["default"].createElement(_components.MetaText, {
@@ -305,7 +306,8 @@ function (_super) {
305
306
  groupId: item.id,
306
307
  groupName: (0, _ConfigPanel.getSecondConfigName)(data, item.id)
307
308
  }),
308
- maxHeight: 30
309
+ maxHeight: 30,
310
+ notNeedLazy: true
309
311
  }), item.buttonTag.open && /*#__PURE__*/_react["default"].createElement(_components.MetaButton, {
310
312
  data: item.buttonTag,
311
313
  GAData: __assign(__assign({}, GAData), {
@@ -9,6 +9,18 @@ Object.defineProperty(exports, "compositeDecorator", {
9
9
  return _compositeDecorator["default"];
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "lazy", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _lazyLoadDecorator.lazy;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "lazyDestroy", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _lazyLoadDecorator.lazyDestroy;
22
+ }
23
+ });
12
24
  Object.defineProperty(exports, "metaDecorator", {
13
25
  enumerable: true,
14
26
  get: function get() {
@@ -28,4 +40,6 @@ var _metaDecorator = _interopRequireDefault(require("./metaDecorator"));
28
40
 
29
41
  var _updateConfigDecorator = _interopRequireDefault(require("./updateConfigDecorator"));
30
42
 
43
+ var _lazyLoadDecorator = require("./lazyLoadDecorator");
44
+
31
45
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.lazy = lazy;
7
+ exports.lazyDestroy = void 0;
8
+
9
+ /**
10
+ * 组件懒加载
11
+ * @param refName 所需懒加载的组件ref名
12
+ * @returns
13
+ */
14
+ function lazy(refName) {
15
+ return function (target, name, descriptor) {
16
+ var fn = descriptor.value;
17
+
18
+ descriptor.value = function () {
19
+ var _this = this;
20
+
21
+ var rest = [];
22
+
23
+ for (var _i = 0; _i < arguments.length; _i++) {
24
+ rest[_i] = arguments[_i];
25
+ }
26
+
27
+ this.intersectionObserver = new IntersectionObserver(function (entries) {
28
+ if (entries[0].isIntersecting) {
29
+ if (!_this.state.lazyShow) {
30
+ _this.setState({
31
+ lazyShow: true
32
+ });
33
+ }
34
+ }
35
+ }, {
36
+ root: null,
37
+ // threshold: 0.8,
38
+ rootMargin: '0px 0px 100px 0px'
39
+ });
40
+ this.intersectionObserver.observe(this[refName].current);
41
+ /** 监听状态变化 */
42
+
43
+ this._intersectionObserverDestroy = function () {
44
+ _this.intersectionObserver.disconnect(_this[refName].current);
45
+ };
46
+
47
+ fn.apply(this, rest);
48
+ };
49
+ };
50
+ }
51
+ /**
52
+ * 销毁lazy监听
53
+ */
54
+
55
+
56
+ var lazyDestroy = function lazyDestroy(target, name, descriptor) {
57
+ var fn = descriptor.value;
58
+
59
+ descriptor.value = function () {
60
+ var rest = [];
61
+
62
+ for (var _i = 0; _i < arguments.length; _i++) {
63
+ rest[_i] = arguments[_i];
64
+ }
65
+
66
+ if (this._intersectionObserverDestroy) {
67
+ this._intersectionObserverDestroy();
68
+ } // this._intersectionObserverDestroy && this._intersectionObserverDestroy();
69
+
70
+
71
+ fn.apply(this, rest);
72
+ };
73
+ };
74
+
75
+ exports.lazyDestroy = lazyDestroy;
@@ -21,6 +21,8 @@ var _commonUtil = require("../../../utils/commonUtil");
21
21
 
22
22
  var _decorator = require("../../../decorator");
23
23
 
24
+ var _ImageLazy = _interopRequireDefault(require("../../../common/ImageLazy"));
25
+
24
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
25
27
 
26
28
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
@@ -165,7 +167,8 @@ function (_super) {
165
167
  var _c = this.props,
166
168
  data = _c.data,
167
169
  isBackground = _c.isBackground,
168
- hoverState = _c.hoverState;
170
+ hoverState = _c.hoverState,
171
+ notNeedLazy = _c.notNeedLazy;
169
172
  var hoverImgSrc = this.state.hoverImgSrc; // const { hoverSrc } = this.state;
170
173
  // console.log('--metaImage ', this.props);
171
174
 
@@ -190,7 +193,7 @@ function (_super) {
190
193
  onClick: function onClick() {
191
194
  (0, _coreUtil.clickUrl)(data.content.clickUrl);
192
195
  }
193
- }, srcImg && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("img", {
196
+ }, srcImg && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, notNeedLazy ? /*#__PURE__*/_react["default"].createElement("img", {
194
197
  ref: this.imgRef,
195
198
  onLoad: function onLoad() {
196
199
  var scale = _this.imgRef.current.clientWidth / 600;
@@ -203,6 +206,18 @@ function (_super) {
203
206
  onMouseLeave: this.mouseLeaveImg,
204
207
  src: srcImg,
205
208
  style: (0, _commonUtil.pxToRem)(this.getStyle())
209
+ }) : /*#__PURE__*/_react["default"].createElement(_ImageLazy["default"], {
210
+ onLoadFunc: function onLoadFunc(clientWidth) {
211
+ var scale = clientWidth / 600;
212
+
213
+ _this.setState({
214
+ scale: scale
215
+ });
216
+ },
217
+ onMouseEnter: this.mouseEnterImg,
218
+ onMouseLeave: this.mouseLeaveImg,
219
+ src: srcImg,
220
+ style: (0, _commonUtil.pxToRem)(this.getStyle())
206
221
  }), areas && areas.length > 0 && areas.map(function (v, i) {
207
222
  var aStyle = {
208
223
  position: 'absolute',
@@ -230,7 +245,8 @@ function (_super) {
230
245
  isBackground: false,
231
246
  hoverState: false,
232
247
  limitWidthHeight: false,
233
- scale: 1
248
+ scale: 1,
249
+ notNeedLazy: false
234
250
  };
235
251
  Image = __decorate([_decorator.metaDecorator], Image);
236
252
  return Image;
@@ -100,9 +100,11 @@ function (_super) {
100
100
 
101
101
  this.intersectionObserver = new IntersectionObserver(function (entries) {
102
102
  if (entries[0].isIntersecting) {
103
- _this.setState({
104
- show: true
105
- });
103
+ if (!_this.state.show) {
104
+ _this.setState({
105
+ show: true
106
+ });
107
+ }
106
108
  }
107
109
  }, {
108
110
  root: (_a = this.props) === null || _a === void 0 ? void 0 : _a.rootContainer(),
@@ -120,14 +122,13 @@ function (_super) {
120
122
  var _this = this;
121
123
 
122
124
  var _a = this.props,
123
- root = _a.root,
124
125
  _b = _a.lazy,
125
126
  lazy = _b === void 0 ? true : _b,
126
127
  src = _a.src,
127
128
  onLoadFunc = _a.onLoadFunc,
128
129
  style = _a.style,
129
130
  className = _a.className,
130
- rest = __rest(_a, ["root", "lazy", "src", "onLoadFunc", "style", "className"]);
131
+ rest = __rest(_a, ["lazy", "src", "onLoadFunc", "style", "className"]);
131
132
 
132
133
  var show = this.state.show;
133
134
  var isShow = lazy ? show : true;
@@ -15,6 +15,8 @@ var _defaultJSON = require("./defaultJSON");
15
15
 
16
16
  var _compositeDecorator = _interopRequireDefault(require("../../../../decorator/compositeDecorator"));
17
17
 
18
+ var _decorator = require("../../../../decorator");
19
+
18
20
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
19
21
 
20
22
  function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
@@ -65,21 +67,43 @@ function (_super) {
65
67
  __extends(Carousel, _super);
66
68
 
67
69
  function Carousel() {
68
- return _super !== null && _super.apply(this, arguments) || this;
70
+ var _this = _super !== null && _super.apply(this, arguments) || this;
71
+
72
+ _this.state = {
73
+ lazyShow: false
74
+ };
75
+ _this.carouselRef = /*#__PURE__*/_react["default"].createRef();
76
+ _this.intersectionObserver = null;
77
+ return _this;
69
78
  }
70
79
 
80
+ Carousel.prototype.componentDidMount = function () {};
81
+
82
+ Carousel.prototype.componentWillUnmount = function () {};
83
+
71
84
  Carousel.prototype.render = function () {
72
85
  var nodeData = this.props.nodeData;
73
- return /*#__PURE__*/_react["default"].createElement("div", null, window.magicDesign.device === 'pc' ? /*#__PURE__*/_react["default"].createElement(_pc["default"], {
86
+ var lazyShow = this.state.lazyShow;
87
+ return /*#__PURE__*/_react["default"].createElement("div", {
88
+ ref: this.carouselRef,
89
+ style: {
90
+ height: lazyShow ? 'auto' : 300
91
+ }
92
+ }, lazyShow && (window.magicDesign.device === 'pc' ? /*#__PURE__*/_react["default"].createElement(_pc["default"], {
74
93
  data: nodeData
75
94
  }) : /*#__PURE__*/_react["default"].createElement(_mobile["default"], {
76
95
  data: nodeData
77
- }));
96
+ })));
78
97
  };
79
98
 
80
99
  Carousel.defaultProps = {};
81
100
  Carousel.type = 'CAROUSEL';
82
101
  Carousel.getDefaultJSON = _defaultJSON.getDefaultJSON;
102
+
103
+ __decorate([(0, _decorator.lazy)('carouselRef')], Carousel.prototype, "componentDidMount", null);
104
+
105
+ __decorate([_decorator.lazyDestroy], Carousel.prototype, "componentWillUnmount", null);
106
+
83
107
  Carousel = __decorate([_compositeDecorator["default"]], Carousel);
84
108
  return Carousel;
85
109
  }(_react.Component);
@@ -73,24 +73,13 @@ var __assign = void 0 && (void 0).__assign || function () {
73
73
  return __assign.apply(this, arguments);
74
74
  };
75
75
 
76
- var MOBILE_IMG_SIZE = {
77
- 1: {
78
- maxH: 282
79
- },
80
- 2: {
81
- maxH: 137
82
- },
83
- 3: {
84
- maxH: 87
85
- },
86
- 4: {
87
- maxH: 66
88
- },
89
- 5: {
90
- maxH: 50
91
- }
92
- };
93
-
76
+ // const MOBILE_IMG_SIZE = {
77
+ // 1: { maxH: 282 },
78
+ // 2: { maxH: 137 },
79
+ // 3: { maxH: 87 },
80
+ // 4: { maxH: 66 },
81
+ // 5: { maxH: 50 },
82
+ // };
94
83
  var CarouselMobile =
95
84
  /** @class */
96
85
  function (_super) {
@@ -247,7 +236,8 @@ function (_super) {
247
236
  GAData: __assign(__assign({}, GAData), {
248
237
  groupId: item.id,
249
238
  groupName: (0, _ConfigPanel.getSecondConfigName)(data, item.id)
250
- })
239
+ }),
240
+ notNeedLazy: true
251
241
  })), layout === 'layout2' && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, item.title.open && /*#__PURE__*/_react["default"].createElement("div", {
252
242
  className: "title"
253
243
  }, /*#__PURE__*/_react["default"].createElement(_components.MetaText, {
@@ -272,7 +262,8 @@ function (_super) {
272
262
  groupId: item.id,
273
263
  groupName: (0, _ConfigPanel.getSecondConfigName)(data, item.id)
274
264
  }),
275
- maxHeight: 20
265
+ maxHeight: 20,
266
+ notNeedLazy: true
276
267
  }), item.buttonTag.open && /*#__PURE__*/_react["default"].createElement(_components.MetaButton, {
277
268
  data: item.buttonTag,
278
269
  GAData: __assign(__assign({}, GAData), {
@@ -280,7 +280,8 @@ function (_super) {
280
280
  }),
281
281
  maxHeight: item.image.content.pcImgSrc ? 'unset' : PC_IMG_SIZE[floorColNum].defH,
282
282
  minHeight: PC_IMG_SIZE[floorColNum].minH,
283
- minWidth: PC_IMG_SIZE[floorColNum].minW
283
+ minWidth: PC_IMG_SIZE[floorColNum].minW,
284
+ notNeedLazy: true
284
285
  })), layout === 'layout2' && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, item.title.open && !((0, _coreUtil.isPc)() && item.title.pcText === '') && /*#__PURE__*/_react["default"].createElement("div", {
285
286
  className: "title"
286
287
  }, /*#__PURE__*/_react["default"].createElement(_components.MetaText, {
@@ -305,7 +306,8 @@ function (_super) {
305
306
  groupId: item.id,
306
307
  groupName: (0, _ConfigPanel.getSecondConfigName)(data, item.id)
307
308
  }),
308
- maxHeight: 30
309
+ maxHeight: 30,
310
+ notNeedLazy: true
309
311
  }), item.buttonTag.open && /*#__PURE__*/_react["default"].createElement(_components.MetaButton, {
310
312
  data: item.buttonTag,
311
313
  GAData: __assign(__assign({}, GAData), {
@@ -9,6 +9,18 @@ Object.defineProperty(exports, "compositeDecorator", {
9
9
  return _compositeDecorator["default"];
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "lazy", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _lazyLoadDecorator.lazy;
16
+ }
17
+ });
18
+ Object.defineProperty(exports, "lazyDestroy", {
19
+ enumerable: true,
20
+ get: function get() {
21
+ return _lazyLoadDecorator.lazyDestroy;
22
+ }
23
+ });
12
24
  Object.defineProperty(exports, "metaDecorator", {
13
25
  enumerable: true,
14
26
  get: function get() {
@@ -28,4 +40,6 @@ var _metaDecorator = _interopRequireDefault(require("./metaDecorator"));
28
40
 
29
41
  var _updateConfigDecorator = _interopRequireDefault(require("./updateConfigDecorator"));
30
42
 
43
+ var _lazyLoadDecorator = require("./lazyLoadDecorator");
44
+
31
45
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
@@ -0,0 +1,75 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
6
+ exports.lazy = lazy;
7
+ exports.lazyDestroy = void 0;
8
+
9
+ /**
10
+ * 组件懒加载
11
+ * @param refName 所需懒加载的组件ref名
12
+ * @returns
13
+ */
14
+ function lazy(refName) {
15
+ return function (target, name, descriptor) {
16
+ var fn = descriptor.value;
17
+
18
+ descriptor.value = function () {
19
+ var _this = this;
20
+
21
+ var rest = [];
22
+
23
+ for (var _i = 0; _i < arguments.length; _i++) {
24
+ rest[_i] = arguments[_i];
25
+ }
26
+
27
+ this.intersectionObserver = new IntersectionObserver(function (entries) {
28
+ if (entries[0].isIntersecting) {
29
+ if (!_this.state.lazyShow) {
30
+ _this.setState({
31
+ lazyShow: true
32
+ });
33
+ }
34
+ }
35
+ }, {
36
+ root: null,
37
+ // threshold: 0.8,
38
+ rootMargin: '0px 0px 100px 0px'
39
+ });
40
+ this.intersectionObserver.observe(this[refName].current);
41
+ /** 监听状态变化 */
42
+
43
+ this._intersectionObserverDestroy = function () {
44
+ _this.intersectionObserver.disconnect(_this[refName].current);
45
+ };
46
+
47
+ fn.apply(this, rest);
48
+ };
49
+ };
50
+ }
51
+ /**
52
+ * 销毁lazy监听
53
+ */
54
+
55
+
56
+ var lazyDestroy = function lazyDestroy(target, name, descriptor) {
57
+ var fn = descriptor.value;
58
+
59
+ descriptor.value = function () {
60
+ var rest = [];
61
+
62
+ for (var _i = 0; _i < arguments.length; _i++) {
63
+ rest[_i] = arguments[_i];
64
+ }
65
+
66
+ if (this._intersectionObserverDestroy) {
67
+ this._intersectionObserverDestroy();
68
+ } // this._intersectionObserverDestroy && this._intersectionObserverDestroy();
69
+
70
+
71
+ fn.apply(this, rest);
72
+ };
73
+ };
74
+
75
+ exports.lazyDestroy = lazyDestroy;
@@ -21,6 +21,8 @@ var _commonUtil = require("../../../utils/commonUtil");
21
21
 
22
22
  var _decorator = require("../../../decorator");
23
23
 
24
+ var _ImageLazy = _interopRequireDefault(require("../../../common/ImageLazy"));
25
+
24
26
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; }
25
27
 
26
28
  function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
@@ -165,7 +167,8 @@ function (_super) {
165
167
  var _c = this.props,
166
168
  data = _c.data,
167
169
  isBackground = _c.isBackground,
168
- hoverState = _c.hoverState;
170
+ hoverState = _c.hoverState,
171
+ notNeedLazy = _c.notNeedLazy;
169
172
  var hoverImgSrc = this.state.hoverImgSrc; // const { hoverSrc } = this.state;
170
173
  // console.log('--metaImage ', this.props);
171
174
 
@@ -190,7 +193,7 @@ function (_super) {
190
193
  onClick: function onClick() {
191
194
  (0, _coreUtil.clickUrl)(data.content.clickUrl);
192
195
  }
193
- }, srcImg && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, /*#__PURE__*/_react["default"].createElement("img", {
196
+ }, srcImg && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, notNeedLazy ? /*#__PURE__*/_react["default"].createElement("img", {
194
197
  ref: this.imgRef,
195
198
  onLoad: function onLoad() {
196
199
  var scale = _this.imgRef.current.clientWidth / 600;
@@ -203,6 +206,18 @@ function (_super) {
203
206
  onMouseLeave: this.mouseLeaveImg,
204
207
  src: srcImg,
205
208
  style: (0, _commonUtil.pxToRem)(this.getStyle())
209
+ }) : /*#__PURE__*/_react["default"].createElement(_ImageLazy["default"], {
210
+ onLoadFunc: function onLoadFunc(clientWidth) {
211
+ var scale = clientWidth / 600;
212
+
213
+ _this.setState({
214
+ scale: scale
215
+ });
216
+ },
217
+ onMouseEnter: this.mouseEnterImg,
218
+ onMouseLeave: this.mouseLeaveImg,
219
+ src: srcImg,
220
+ style: (0, _commonUtil.pxToRem)(this.getStyle())
206
221
  }), areas && areas.length > 0 && areas.map(function (v, i) {
207
222
  var aStyle = {
208
223
  position: 'absolute',
@@ -230,7 +245,8 @@ function (_super) {
230
245
  isBackground: false,
231
246
  hoverState: false,
232
247
  limitWidthHeight: false,
233
- scale: 1
248
+ scale: 1,
249
+ notNeedLazy: false
234
250
  };
235
251
  Image = __decorate([_decorator.metaDecorator], Image);
236
252
  return Image;
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fonixtree/magic-design",
3
3
  "author": "Cylon Team",
4
- "version": "2.0.29",
4
+ "version": "2.0.31",
5
5
  "description": "Magic Design",
6
6
  "license": "MIT",
7
7
  "module": "es/index.js",
Binary file
Binary file