@fonixtree/magic-design 2.0.29 → 2.0.30

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.
@@ -65,16 +65,47 @@ function (_super) {
65
65
  __extends(Carousel, _super);
66
66
 
67
67
  function Carousel() {
68
- return _super !== null && _super.apply(this, arguments) || this;
68
+ var _this = _super !== null && _super.apply(this, arguments) || this;
69
+
70
+ _this.state = {
71
+ show: false
72
+ };
73
+ _this.carouselRef = /*#__PURE__*/_react["default"].createRef();
74
+ _this.intersectionObserver = null;
75
+ return _this;
69
76
  }
70
77
 
78
+ Carousel.prototype.componentDidMount = function () {
79
+ var _this = this;
80
+
81
+ this.intersectionObserver = new IntersectionObserver(function (entries) {
82
+ if (entries[0].isIntersecting) {
83
+ _this.setState({
84
+ show: true
85
+ });
86
+ }
87
+ }, {
88
+ root: null,
89
+ // threshold: 0.8,
90
+ rootMargin: '0px 0px 100px 0px'
91
+ });
92
+ this.intersectionObserver.observe(this.carouselRef.current);
93
+ };
94
+
95
+ Carousel.prototype.componentWillUnmount = function () {
96
+ this.intersectionObserver.disconnect(this.carouselRef.current);
97
+ };
98
+
71
99
  Carousel.prototype.render = function () {
72
100
  var nodeData = this.props.nodeData;
73
- return /*#__PURE__*/_react["default"].createElement("div", null, window.magicDesign.device === 'pc' ? /*#__PURE__*/_react["default"].createElement(_pc["default"], {
101
+ var show = this.state.show;
102
+ return /*#__PURE__*/_react["default"].createElement("div", {
103
+ ref: this.carouselRef
104
+ }, show && (window.magicDesign.device === 'pc' ? /*#__PURE__*/_react["default"].createElement(_pc["default"], {
74
105
  data: nodeData
75
106
  }) : /*#__PURE__*/_react["default"].createElement(_mobile["default"], {
76
107
  data: nodeData
77
- }));
108
+ })));
78
109
  };
79
110
 
80
111
  Carousel.defaultProps = {};
@@ -247,7 +247,8 @@ function (_super) {
247
247
  GAData: __assign(__assign({}, GAData), {
248
248
  groupId: item.id,
249
249
  groupName: (0, _ConfigPanel.getSecondConfigName)(data, item.id)
250
- })
250
+ }),
251
+ notNeedLazy: true
251
252
  })), layout === 'layout2' && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, item.title.open && /*#__PURE__*/_react["default"].createElement("div", {
252
253
  className: "title"
253
254
  }, /*#__PURE__*/_react["default"].createElement(_components.MetaText, {
@@ -272,7 +273,8 @@ function (_super) {
272
273
  groupId: item.id,
273
274
  groupName: (0, _ConfigPanel.getSecondConfigName)(data, item.id)
274
275
  }),
275
- maxHeight: 20
276
+ maxHeight: 20,
277
+ notNeedLazy: true
276
278
  }), item.buttonTag.open && /*#__PURE__*/_react["default"].createElement(_components.MetaButton, {
277
279
  data: item.buttonTag,
278
280
  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), {
@@ -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;
@@ -65,16 +65,47 @@ function (_super) {
65
65
  __extends(Carousel, _super);
66
66
 
67
67
  function Carousel() {
68
- return _super !== null && _super.apply(this, arguments) || this;
68
+ var _this = _super !== null && _super.apply(this, arguments) || this;
69
+
70
+ _this.state = {
71
+ show: false
72
+ };
73
+ _this.carouselRef = /*#__PURE__*/_react["default"].createRef();
74
+ _this.intersectionObserver = null;
75
+ return _this;
69
76
  }
70
77
 
78
+ Carousel.prototype.componentDidMount = function () {
79
+ var _this = this;
80
+
81
+ this.intersectionObserver = new IntersectionObserver(function (entries) {
82
+ if (entries[0].isIntersecting) {
83
+ _this.setState({
84
+ show: true
85
+ });
86
+ }
87
+ }, {
88
+ root: null,
89
+ // threshold: 0.8,
90
+ rootMargin: '0px 0px 100px 0px'
91
+ });
92
+ this.intersectionObserver.observe(this.carouselRef.current);
93
+ };
94
+
95
+ Carousel.prototype.componentWillUnmount = function () {
96
+ this.intersectionObserver.disconnect(this.carouselRef.current);
97
+ };
98
+
71
99
  Carousel.prototype.render = function () {
72
100
  var nodeData = this.props.nodeData;
73
- return /*#__PURE__*/_react["default"].createElement("div", null, window.magicDesign.device === 'pc' ? /*#__PURE__*/_react["default"].createElement(_pc["default"], {
101
+ var show = this.state.show;
102
+ return /*#__PURE__*/_react["default"].createElement("div", {
103
+ ref: this.carouselRef
104
+ }, show && (window.magicDesign.device === 'pc' ? /*#__PURE__*/_react["default"].createElement(_pc["default"], {
74
105
  data: nodeData
75
106
  }) : /*#__PURE__*/_react["default"].createElement(_mobile["default"], {
76
107
  data: nodeData
77
- }));
108
+ })));
78
109
  };
79
110
 
80
111
  Carousel.defaultProps = {};
@@ -247,7 +247,8 @@ function (_super) {
247
247
  GAData: __assign(__assign({}, GAData), {
248
248
  groupId: item.id,
249
249
  groupName: (0, _ConfigPanel.getSecondConfigName)(data, item.id)
250
- })
250
+ }),
251
+ notNeedLazy: true
251
252
  })), layout === 'layout2' && /*#__PURE__*/_react["default"].createElement(_react["default"].Fragment, null, item.title.open && /*#__PURE__*/_react["default"].createElement("div", {
252
253
  className: "title"
253
254
  }, /*#__PURE__*/_react["default"].createElement(_components.MetaText, {
@@ -272,7 +273,8 @@ function (_super) {
272
273
  groupId: item.id,
273
274
  groupName: (0, _ConfigPanel.getSecondConfigName)(data, item.id)
274
275
  }),
275
- maxHeight: 20
276
+ maxHeight: 20,
277
+ notNeedLazy: true
276
278
  }), item.buttonTag.open && /*#__PURE__*/_react["default"].createElement(_components.MetaButton, {
277
279
  data: item.buttonTag,
278
280
  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), {
@@ -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.30",
5
5
  "description": "Magic Design",
6
6
  "license": "MIT",
7
7
  "module": "es/index.js",