@fonixtree/magic-design 1.0.152 → 1.0.153

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.
@@ -63,7 +63,8 @@ function ProductCardModal(_a) {
63
63
  };
64
64
 
65
65
  var randomRotateY = function randomRotateY() {
66
- return Math.floor(Math.random() * 21) - 10;
66
+ // return Math.floor(Math.random() * 21) - 10;
67
+ return Math.floor((index % 2 === 0 ? -index : index) * 0.1 * 21) - 10;
67
68
  };
68
69
 
69
70
  var handleScroll = function handleScroll(e) {
@@ -61,6 +61,7 @@
61
61
  top: 5%;
62
62
  right: 5%;
63
63
  cursor: pointer;
64
+ z-index: 3;
64
65
  }
65
66
 
66
67
  .dotIcon {
@@ -96,6 +97,7 @@
96
97
  position: absolute;
97
98
  bottom: 25%;
98
99
  left: 55%;
100
+ z-index: 3;
99
101
  cursor: pointer;
100
102
  }
101
103
  }
@@ -54,10 +54,12 @@ function (_super) {
54
54
  inside: false,
55
55
  isNearCenter: false,
56
56
  flag: false,
57
- corner: ''
57
+ corner: '',
58
+ videoPoster: ''
58
59
  };
59
60
  _this.videoRef = /*#__PURE__*/_react["default"].createRef();
60
61
  _this.cardRef = /*#__PURE__*/_react["default"].createRef();
62
+ _this.canvasRef = /*#__PURE__*/_react["default"].createRef();
61
63
 
62
64
  _this.onMouseEnter = function () {
63
65
  var _a;
@@ -157,9 +159,32 @@ function (_super) {
157
159
  }
158
160
 
159
161
  VideoItem.prototype.componentDidMount = function () {
162
+ var _this = this;
163
+
160
164
  var dom = this.cardRef.current;
161
165
  dom.addEventListener('mousemove', this.handleMouseMove);
162
166
  dom.addEventListener('mouseleave', this.handleMouseLeave);
167
+
168
+ if (this.videoRef.current) {
169
+ var video_1 = this.videoRef.current;
170
+ var canvas_1 = this.canvasRef.current;
171
+ video_1.addEventListener('loadedmetadata', function () {
172
+ // 确保跳转到第一帧
173
+ video_1.currentTime = 0;
174
+ });
175
+ video_1.addEventListener('seeked', function () {
176
+ // 设置Canvas尺寸与视频一致
177
+ canvas_1.width = video_1.offsetWidth;
178
+ canvas_1.height = video_1.offsetHeight; // 绘制视频帧到Canvas
179
+
180
+ var ctx = canvas_1.getContext('2d');
181
+ ctx.drawImage(video_1, 0, 0, canvas_1.width, canvas_1.height); // 转换为缩略图
182
+
183
+ _this.setState({
184
+ videoPoster: canvas_1.toDataURL('image/png')
185
+ });
186
+ });
187
+ }
163
188
  };
164
189
 
165
190
  VideoItem.prototype.componentWillUnmount = function () {
@@ -171,21 +196,23 @@ function (_super) {
171
196
  VideoItem.prototype.render = function () {
172
197
  var _a;
173
198
 
174
- var _b, _c, _d, _e, _f;
199
+ var _b, _c, _d, _e, _f, _g;
175
200
 
176
201
  var data = this.props.data;
177
- var _g = this.state,
178
- playing = _g.playing,
179
- inside = _g.inside,
180
- isNearCenter = _g.isNearCenter,
181
- flag = _g.flag,
182
- corner = _g.corner;
202
+ var _h = this.state,
203
+ playing = _h.playing,
204
+ inside = _h.inside,
205
+ isNearCenter = _h.isNearCenter,
206
+ flag = _h.flag,
207
+ corner = _h.corner,
208
+ videoPoster = _h.videoPoster;
209
+ var img = ((_c = (_b = data.overilay) === null || _b === void 0 ? void 0 : _b.content) === null || _c === void 0 ? void 0 : _c.pcImgSrc) || videoPoster;
183
210
  return /*#__PURE__*/_react["default"].createElement("div", {
184
211
  ref: this.cardRef,
185
212
  className: (0, _classnames["default"])('slide-image-video-wrap', (_a = {}, _a[corner] = inside && !isNearCenter && !flag, _a)),
186
213
  onMouseEnter: this.onMouseEnter,
187
214
  onMouseLeave: this.onMouseLeave
188
- }, ((_b = data.video) === null || _b === void 0 ? void 0 : _b.sourceUrl) && /*#__PURE__*/_react["default"].createElement("video", {
215
+ }, ((_d = data.video) === null || _d === void 0 ? void 0 : _d.sourceUrl) && /*#__PURE__*/_react["default"].createElement("video", {
189
216
  ref: this.videoRef,
190
217
  loop: true,
191
218
  muted: true,
@@ -194,15 +221,19 @@ function (_super) {
194
221
  visibility: playing ? 'visible' : 'hidden'
195
222
  }
196
223
  }, /*#__PURE__*/_react["default"].createElement("source", {
197
- src: (_c = data.video) === null || _c === void 0 ? void 0 : _c.sourceUrl,
224
+ src: (_e = data.video) === null || _e === void 0 ? void 0 : _e.sourceUrl,
198
225
  type: "video/mp4"
199
- })), ((_d = data.overilay) === null || _d === void 0 ? void 0 : _d.open) && /*#__PURE__*/_react["default"].createElement("img", {
226
+ })), ((_f = data.overilay) === null || _f === void 0 ? void 0 : _f.open) && img && /*#__PURE__*/_react["default"].createElement("img", {
200
227
  alt: "",
201
- className: "video-img",
202
- src: (_f = (_e = data.overilay) === null || _e === void 0 ? void 0 : _e.content) === null || _f === void 0 ? void 0 : _f.pcImgSrc,
228
+ className: (0, _classnames["default"])('video-img', {
229
+ cover: (_g = data.video) === null || _g === void 0 ? void 0 : _g.sourceUrl
230
+ }),
231
+ src: img,
203
232
  style: {
204
233
  visibility: playing ? 'hidden' : 'visible'
205
234
  }
235
+ }), /*#__PURE__*/_react["default"].createElement("canvas", {
236
+ ref: this.canvasRef
206
237
  }));
207
238
  };
208
239
 
@@ -2,9 +2,10 @@
2
2
  position: relative;
3
3
  transition: border-radius 0.2s ease;
4
4
  overflow: hidden;
5
- cursor: pointer;
5
+ display: flex;
6
6
  --dx: calc(var(--size) - var(--x));
7
7
  --dy: calc(var(--size) - var(--y));
8
+ cursor: url('./imgs/cursor.png'), pointer;
8
9
 
9
10
  // &.hover {
10
11
  // border-radius:
@@ -67,18 +68,26 @@
67
68
  }
68
69
 
69
70
  video {
70
- position: absolute;
71
- top: 0;
72
- right: 0;
73
- left: 0;
74
- bottom: 0;
75
- object-fit: cover;
76
71
  width: 100%;
77
- height: 100%;
78
- z-index: 2;
79
72
  }
80
73
 
81
74
  .video-img {
82
75
  width: 100%;
76
+
77
+ &.cover {
78
+ position: absolute;
79
+ top: 0;
80
+ right: 0;
81
+ left: 0;
82
+ bottom: 0;
83
+ object-fit: cover;
84
+ width: 100%;
85
+ height: 100%;
86
+ z-index: 2;
87
+ }
88
+ }
89
+
90
+ canvas {
91
+ display: none;
83
92
  }
84
93
  }
@@ -282,6 +282,7 @@ function (_super) {
282
282
  split: true,
283
283
  title: "URL"
284
284
  }, /*#__PURE__*/_react["default"].createElement(_common.UrlPicker, {
285
+ disabled: true,
285
286
  onChange: function onChange(v) {
286
287
  textData.clickUrl = v;
287
288
 
@@ -63,7 +63,8 @@ function ProductCardModal(_a) {
63
63
  };
64
64
 
65
65
  var randomRotateY = function randomRotateY() {
66
- return Math.floor(Math.random() * 21) - 10;
66
+ // return Math.floor(Math.random() * 21) - 10;
67
+ return Math.floor((index % 2 === 0 ? -index : index) * 0.1 * 21) - 10;
67
68
  };
68
69
 
69
70
  var handleScroll = function handleScroll(e) {
@@ -61,6 +61,7 @@
61
61
  top: 5%;
62
62
  right: 5%;
63
63
  cursor: pointer;
64
+ z-index: 3;
64
65
  }
65
66
 
66
67
  .dotIcon {
@@ -96,6 +97,7 @@
96
97
  position: absolute;
97
98
  bottom: 25%;
98
99
  left: 55%;
100
+ z-index: 3;
99
101
  cursor: pointer;
100
102
  }
101
103
  }
@@ -54,10 +54,12 @@ function (_super) {
54
54
  inside: false,
55
55
  isNearCenter: false,
56
56
  flag: false,
57
- corner: ''
57
+ corner: '',
58
+ videoPoster: ''
58
59
  };
59
60
  _this.videoRef = /*#__PURE__*/_react["default"].createRef();
60
61
  _this.cardRef = /*#__PURE__*/_react["default"].createRef();
62
+ _this.canvasRef = /*#__PURE__*/_react["default"].createRef();
61
63
 
62
64
  _this.onMouseEnter = function () {
63
65
  var _a;
@@ -157,9 +159,32 @@ function (_super) {
157
159
  }
158
160
 
159
161
  VideoItem.prototype.componentDidMount = function () {
162
+ var _this = this;
163
+
160
164
  var dom = this.cardRef.current;
161
165
  dom.addEventListener('mousemove', this.handleMouseMove);
162
166
  dom.addEventListener('mouseleave', this.handleMouseLeave);
167
+
168
+ if (this.videoRef.current) {
169
+ var video_1 = this.videoRef.current;
170
+ var canvas_1 = this.canvasRef.current;
171
+ video_1.addEventListener('loadedmetadata', function () {
172
+ // 确保跳转到第一帧
173
+ video_1.currentTime = 0;
174
+ });
175
+ video_1.addEventListener('seeked', function () {
176
+ // 设置Canvas尺寸与视频一致
177
+ canvas_1.width = video_1.offsetWidth;
178
+ canvas_1.height = video_1.offsetHeight; // 绘制视频帧到Canvas
179
+
180
+ var ctx = canvas_1.getContext('2d');
181
+ ctx.drawImage(video_1, 0, 0, canvas_1.width, canvas_1.height); // 转换为缩略图
182
+
183
+ _this.setState({
184
+ videoPoster: canvas_1.toDataURL('image/png')
185
+ });
186
+ });
187
+ }
163
188
  };
164
189
 
165
190
  VideoItem.prototype.componentWillUnmount = function () {
@@ -171,21 +196,23 @@ function (_super) {
171
196
  VideoItem.prototype.render = function () {
172
197
  var _a;
173
198
 
174
- var _b, _c, _d, _e, _f;
199
+ var _b, _c, _d, _e, _f, _g;
175
200
 
176
201
  var data = this.props.data;
177
- var _g = this.state,
178
- playing = _g.playing,
179
- inside = _g.inside,
180
- isNearCenter = _g.isNearCenter,
181
- flag = _g.flag,
182
- corner = _g.corner;
202
+ var _h = this.state,
203
+ playing = _h.playing,
204
+ inside = _h.inside,
205
+ isNearCenter = _h.isNearCenter,
206
+ flag = _h.flag,
207
+ corner = _h.corner,
208
+ videoPoster = _h.videoPoster;
209
+ var img = ((_c = (_b = data.overilay) === null || _b === void 0 ? void 0 : _b.content) === null || _c === void 0 ? void 0 : _c.pcImgSrc) || videoPoster;
183
210
  return /*#__PURE__*/_react["default"].createElement("div", {
184
211
  ref: this.cardRef,
185
212
  className: (0, _classnames["default"])('slide-image-video-wrap', (_a = {}, _a[corner] = inside && !isNearCenter && !flag, _a)),
186
213
  onMouseEnter: this.onMouseEnter,
187
214
  onMouseLeave: this.onMouseLeave
188
- }, ((_b = data.video) === null || _b === void 0 ? void 0 : _b.sourceUrl) && /*#__PURE__*/_react["default"].createElement("video", {
215
+ }, ((_d = data.video) === null || _d === void 0 ? void 0 : _d.sourceUrl) && /*#__PURE__*/_react["default"].createElement("video", {
189
216
  ref: this.videoRef,
190
217
  loop: true,
191
218
  muted: true,
@@ -194,15 +221,19 @@ function (_super) {
194
221
  visibility: playing ? 'visible' : 'hidden'
195
222
  }
196
223
  }, /*#__PURE__*/_react["default"].createElement("source", {
197
- src: (_c = data.video) === null || _c === void 0 ? void 0 : _c.sourceUrl,
224
+ src: (_e = data.video) === null || _e === void 0 ? void 0 : _e.sourceUrl,
198
225
  type: "video/mp4"
199
- })), ((_d = data.overilay) === null || _d === void 0 ? void 0 : _d.open) && /*#__PURE__*/_react["default"].createElement("img", {
226
+ })), ((_f = data.overilay) === null || _f === void 0 ? void 0 : _f.open) && img && /*#__PURE__*/_react["default"].createElement("img", {
200
227
  alt: "",
201
- className: "video-img",
202
- src: (_f = (_e = data.overilay) === null || _e === void 0 ? void 0 : _e.content) === null || _f === void 0 ? void 0 : _f.pcImgSrc,
228
+ className: (0, _classnames["default"])('video-img', {
229
+ cover: (_g = data.video) === null || _g === void 0 ? void 0 : _g.sourceUrl
230
+ }),
231
+ src: img,
203
232
  style: {
204
233
  visibility: playing ? 'hidden' : 'visible'
205
234
  }
235
+ }), /*#__PURE__*/_react["default"].createElement("canvas", {
236
+ ref: this.canvasRef
206
237
  }));
207
238
  };
208
239
 
@@ -2,9 +2,10 @@
2
2
  position: relative;
3
3
  transition: border-radius 0.2s ease;
4
4
  overflow: hidden;
5
- cursor: pointer;
5
+ display: flex;
6
6
  --dx: calc(var(--size) - var(--x));
7
7
  --dy: calc(var(--size) - var(--y));
8
+ cursor: url('./imgs/cursor.png'), pointer;
8
9
 
9
10
  // &.hover {
10
11
  // border-radius:
@@ -67,18 +68,26 @@
67
68
  }
68
69
 
69
70
  video {
70
- position: absolute;
71
- top: 0;
72
- right: 0;
73
- left: 0;
74
- bottom: 0;
75
- object-fit: cover;
76
71
  width: 100%;
77
- height: 100%;
78
- z-index: 2;
79
72
  }
80
73
 
81
74
  .video-img {
82
75
  width: 100%;
76
+
77
+ &.cover {
78
+ position: absolute;
79
+ top: 0;
80
+ right: 0;
81
+ left: 0;
82
+ bottom: 0;
83
+ object-fit: cover;
84
+ width: 100%;
85
+ height: 100%;
86
+ z-index: 2;
87
+ }
88
+ }
89
+
90
+ canvas {
91
+ display: none;
83
92
  }
84
93
  }
@@ -282,6 +282,7 @@ function (_super) {
282
282
  split: true,
283
283
  title: "URL"
284
284
  }, /*#__PURE__*/_react["default"].createElement(_common.UrlPicker, {
285
+ disabled: true,
285
286
  onChange: function onChange(v) {
286
287
  textData.clickUrl = v;
287
288
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@fonixtree/magic-design",
3
3
  "author": "Cylon Team",
4
- "version": "1.0.152",
4
+ "version": "1.0.153",
5
5
  "description": "Magic Design",
6
6
  "license": "MIT",
7
7
  "module": "es/index.js",