@fonixtree/magic-design 1.0.151 → 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.
- package/es/common/ProductCardModal/index.js +43 -2
- package/es/common/ProductCardModal/index.less +2 -0
- package/es/composite-comp/dito/components/SlideImage/pc/components/CardItem/index.js +3 -5
- package/es/composite-comp/dito/components/SlideImage/pc/components/CardItem/index.less +1 -4
- package/es/composite-comp/dito/components/SlideImage/pc/components/VideoItem/imgs/cursor.png +0 -0
- package/es/composite-comp/dito/components/SlideImage/pc/components/VideoItem/index.js +46 -17
- package/es/composite-comp/dito/components/SlideImage/pc/components/VideoItem/index.less +18 -11
- package/es/composite-comp/dito/components/SlideImage/pc/index.js +1 -401
- package/es/composite-comp/dito/components/SlideImage/pc/index.less +1 -12
- package/es/meta-comp/config-panels/TextConfig/index.js +1 -0
- package/lib/common/ProductCardModal/index.js +43 -2
- package/lib/common/ProductCardModal/index.less +2 -0
- package/lib/composite-comp/dito/components/SlideImage/pc/components/CardItem/index.js +3 -5
- package/lib/composite-comp/dito/components/SlideImage/pc/components/CardItem/index.less +1 -4
- package/lib/composite-comp/dito/components/SlideImage/pc/components/VideoItem/imgs/cursor.png +0 -0
- package/lib/composite-comp/dito/components/SlideImage/pc/components/VideoItem/index.js +46 -17
- package/lib/composite-comp/dito/components/SlideImage/pc/components/VideoItem/index.less +18 -11
- package/lib/composite-comp/dito/components/SlideImage/pc/index.js +1 -401
- package/lib/composite-comp/dito/components/SlideImage/pc/index.less +1 -12
- package/lib/meta-comp/config-panels/TextConfig/index.js +1 -0
- package/package.json +1 -1
|
@@ -42,6 +42,8 @@ function ProductCardModal(_a) {
|
|
|
42
42
|
loading = _e[0],
|
|
43
43
|
setLoading = _e[1];
|
|
44
44
|
|
|
45
|
+
var flag = true;
|
|
46
|
+
|
|
45
47
|
var handleNext = function handleNext(e) {
|
|
46
48
|
e.stopPropagation();
|
|
47
49
|
setActive(function (prev) {
|
|
@@ -61,7 +63,38 @@ function ProductCardModal(_a) {
|
|
|
61
63
|
};
|
|
62
64
|
|
|
63
65
|
var randomRotateY = function randomRotateY() {
|
|
64
|
-
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;
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
var handleScroll = function handleScroll(e) {
|
|
71
|
+
if (flag) {
|
|
72
|
+
flag = false; // 统一处理 delta 值
|
|
73
|
+
|
|
74
|
+
var delta = 0;
|
|
75
|
+
|
|
76
|
+
if (e.deltaY) {
|
|
77
|
+
delta = e.deltaY; // 现代浏览器
|
|
78
|
+
} else if (e.wheelDelta) {
|
|
79
|
+
delta = -e.wheelDelta / 40; // 旧版浏览器,调整方向和数值
|
|
80
|
+
} // 判断方向
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
if (delta > 0) {
|
|
84
|
+
console.log('向下滚动..');
|
|
85
|
+
handleNext(e);
|
|
86
|
+
} else if (delta < 0) {
|
|
87
|
+
console.log('向上滚动');
|
|
88
|
+
handlePrev(e);
|
|
89
|
+
} // 阻止默认滚动行为(如需要)
|
|
90
|
+
|
|
91
|
+
|
|
92
|
+
e.preventDefault();
|
|
93
|
+
var scrollTimeout_1 = setTimeout(function () {
|
|
94
|
+
flag = true;
|
|
95
|
+
clearTimeout(scrollTimeout_1);
|
|
96
|
+
}, 2000);
|
|
97
|
+
}
|
|
65
98
|
};
|
|
66
99
|
|
|
67
100
|
(0, _react.useEffect)(function () {
|
|
@@ -70,7 +103,15 @@ function ProductCardModal(_a) {
|
|
|
70
103
|
return function () {
|
|
71
104
|
return clearInterval(interval_1);
|
|
72
105
|
};
|
|
73
|
-
}
|
|
106
|
+
} // 监听滚轮事件(推荐:现代浏览器)
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
document.addEventListener('wheel', handleScroll); // 兼容旧版浏览器(如 IE/旧 WebKit)
|
|
110
|
+
// document.addEventListener('mousewheel', handleScroll);
|
|
111
|
+
|
|
112
|
+
return function () {
|
|
113
|
+
document.removeEventListener('wheel', handleScroll); // document.removeEventListener('mousewheel', handleScroll);
|
|
114
|
+
};
|
|
74
115
|
}, [autoplay]);
|
|
75
116
|
return /*#__PURE__*/_react["default"].createElement("div", {
|
|
76
117
|
className: "productCardModalWrap",
|
|
@@ -81,15 +81,13 @@ function (_super) {
|
|
|
81
81
|
}
|
|
82
82
|
}, rest), /*#__PURE__*/_react["default"].createElement(_VideoItem["default"], {
|
|
83
83
|
data: data
|
|
84
|
-
}), data.groupName.open && /*#__PURE__*/_react["default"].createElement(
|
|
85
|
-
className: "text
|
|
86
|
-
}, /*#__PURE__*/_react["default"].createElement(_components.MetaText, {
|
|
87
|
-
className: "canvas-ignore",
|
|
84
|
+
}), data.groupName.open && /*#__PURE__*/_react["default"].createElement(_components.MetaText, {
|
|
85
|
+
className: "text",
|
|
88
86
|
data: data.groupName,
|
|
89
87
|
style: {
|
|
90
88
|
pointerEvents: (0, _coreUtil.isDesignMode)() ? 'unset' : 'none'
|
|
91
89
|
}
|
|
92
|
-
})))
|
|
90
|
+
})));
|
|
93
91
|
};
|
|
94
92
|
|
|
95
93
|
CardItem.defaultProps = {
|
|
Binary file
|
|
@@ -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 () {
|
|
@@ -169,25 +194,26 @@ function (_super) {
|
|
|
169
194
|
};
|
|
170
195
|
|
|
171
196
|
VideoItem.prototype.render = function () {
|
|
172
|
-
var _a
|
|
197
|
+
var _a;
|
|
173
198
|
|
|
174
|
-
var _c, _d, _e, _f, _g
|
|
199
|
+
var _b, _c, _d, _e, _f, _g;
|
|
175
200
|
|
|
176
201
|
var data = this.props.data;
|
|
177
|
-
var
|
|
178
|
-
playing =
|
|
179
|
-
inside =
|
|
180
|
-
isNearCenter =
|
|
181
|
-
flag =
|
|
182
|
-
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
|
-
}, ((
|
|
215
|
+
}, ((_d = data.video) === null || _d === void 0 ? void 0 : _d.sourceUrl) && /*#__PURE__*/_react["default"].createElement("video", {
|
|
189
216
|
ref: this.videoRef,
|
|
190
|
-
className: "canvas-ignore",
|
|
191
217
|
loop: true,
|
|
192
218
|
muted: true,
|
|
193
219
|
playsinline: true,
|
|
@@ -195,16 +221,19 @@ function (_super) {
|
|
|
195
221
|
visibility: playing ? 'visible' : 'hidden'
|
|
196
222
|
}
|
|
197
223
|
}, /*#__PURE__*/_react["default"].createElement("source", {
|
|
198
|
-
src: (
|
|
224
|
+
src: (_e = data.video) === null || _e === void 0 ? void 0 : _e.sourceUrl,
|
|
199
225
|
type: "video/mp4"
|
|
200
|
-
})), ((
|
|
226
|
+
})), ((_f = data.overilay) === null || _f === void 0 ? void 0 : _f.open) && img && /*#__PURE__*/_react["default"].createElement("img", {
|
|
201
227
|
alt: "",
|
|
202
|
-
className: (0, _classnames["default"])('video-img',
|
|
203
|
-
|
|
228
|
+
className: (0, _classnames["default"])('video-img', {
|
|
229
|
+
cover: (_g = data.video) === null || _g === void 0 ? void 0 : _g.sourceUrl
|
|
230
|
+
}),
|
|
231
|
+
src: img,
|
|
204
232
|
style: {
|
|
205
|
-
visibility: playing ? 'hidden' : 'visible'
|
|
206
|
-
zIndex: ((_j = data.video) === null || _j === void 0 ? void 0 : _j.sourceUrl) ? 3 : 0
|
|
233
|
+
visibility: playing ? 'hidden' : 'visible'
|
|
207
234
|
}
|
|
235
|
+
}), /*#__PURE__*/_react["default"].createElement("canvas", {
|
|
236
|
+
ref: this.canvasRef
|
|
208
237
|
}));
|
|
209
238
|
};
|
|
210
239
|
|
|
@@ -2,9 +2,10 @@
|
|
|
2
2
|
position: relative;
|
|
3
3
|
transition: border-radius 0.2s ease;
|
|
4
4
|
overflow: hidden;
|
|
5
|
-
|
|
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,20 +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%;
|
|
83
|
-
|
|
84
|
-
|
|
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;
|
|
85
92
|
}
|
|
86
93
|
}
|