@rxdrag/website-lib-core 0.0.103 → 0.0.105
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/package.json +5 -5
- package/src/component-logic/index.ts +1 -8
- package/src/global.d.ts +7 -0
- package/src/index.ts +1 -3
- package/src/react/components/BackgroundHlsVideoPlayer.tsx +30 -1
- package/src/react/components/ContactForm/ContactForm.tsx +3 -2
- package/src/react/components/ContactForm/types.ts +1 -0
- package/src/react/components/ProductCard/ProductCta/index.tsx +5 -21
- package/src/react/components/Scroller.tsx +32 -4
- package/src/react/components/Share/socials.tsx +1 -2
- package/src/react/index.ts +1 -2
- package/src/component-logic/collapse.ts +0 -61
- package/src/component-logic/gsap.d.ts +0 -4
- package/src/component-logic/modal.ts +0 -45
- package/src/component-logic/motion.ts +0 -272
- package/src/component-logic/number.ts +0 -45
- package/src/component-logic/popover.ts +0 -51
- package/src/component-logic/tabs.ts +0 -10
- package/src/controller/AnimateController.ts +0 -138
- package/src/controller/AosController.ts +0 -240
- package/src/controller/CollapseController.ts +0 -130
- package/src/controller/FlipController.ts +0 -339
- package/src/controller/ModalController.ts +0 -127
- package/src/controller/NumberController.ts +0 -161
- package/src/controller/OpenableController.ts +0 -367
- package/src/controller/PageLoader.ts +0 -154
- package/src/controller/PopoverController.ts +0 -116
- package/src/controller/TabsController.ts +0 -271
- package/src/controller/applyAnimation.ts +0 -86
- package/src/controller/applyInitialState.ts +0 -79
- package/src/controller/consts.ts +0 -33
- package/src/controller/index.ts +0 -10
- package/src/controller/utils.ts +0 -48
- package/src/motion/consts.ts +0 -428
- package/src/motion/convertToGsapVars.ts +0 -102
- package/src/motion/index.ts +0 -6
- package/src/motion/normalizeAnimation.ts +0 -28
- package/src/motion/normalizeAosAnimation.ts +0 -22
- package/src/motion/normalizePopupAnimation.ts +0 -24
- package/src/motion/types.ts +0 -133
- package/src/react/hooks/index.ts +0 -1
- package/src/react/hooks/useScroll.ts +0 -30
package/src/motion/consts.ts
DELETED
|
@@ -1,428 +0,0 @@
|
|
|
1
|
-
import {
|
|
2
|
-
AnchorOffsets,
|
|
3
|
-
AosAnimationConfig,
|
|
4
|
-
OpenableAnimationConfig,
|
|
5
|
-
AnimationConfig,
|
|
6
|
-
} from "./types";
|
|
7
|
-
|
|
8
|
-
//立即执行
|
|
9
|
-
export const DATA_MOTION = "data-motion";
|
|
10
|
-
|
|
11
|
-
//过渡
|
|
12
|
-
//export const DATA_MOTION_TRANSITION = "data-motion-transition";
|
|
13
|
-
//悬停
|
|
14
|
-
export const DATA_MOTION_HOVER = "data-motion-hover";
|
|
15
|
-
//按压
|
|
16
|
-
export const DATA_MOTION_TAP = "data-motion-tap";
|
|
17
|
-
//入视图
|
|
18
|
-
export const DATA_MOTION_INVIEW = "data-motion-inview";
|
|
19
|
-
//弹层动画,有动作的组件联动
|
|
20
|
-
export const DATA_MOTION_OPENABLE = "data-motion-openable";
|
|
21
|
-
//数字动画
|
|
22
|
-
export const DATA_MOTION_NUMBER = "data-motion-number";
|
|
23
|
-
export const DATA_MOTION_NUMBER_ONCE = "data-motion-number-once";
|
|
24
|
-
|
|
25
|
-
export type PresetAnimations =
|
|
26
|
-
| "fade"
|
|
27
|
-
| "fade-up"
|
|
28
|
-
| "fade-down"
|
|
29
|
-
| "fade-left"
|
|
30
|
-
| "fade-right"
|
|
31
|
-
| "fade-up-right"
|
|
32
|
-
| "fade-up-left"
|
|
33
|
-
| "fade-down-right"
|
|
34
|
-
| "fade-down-left"
|
|
35
|
-
| "flip-up"
|
|
36
|
-
| "flip-down"
|
|
37
|
-
| "flip-left"
|
|
38
|
-
| "flip-right"
|
|
39
|
-
| "slide-up"
|
|
40
|
-
| "slide-down"
|
|
41
|
-
| "slide-left"
|
|
42
|
-
| "slide-right"
|
|
43
|
-
| "rotate"
|
|
44
|
-
| "rotate-scale"
|
|
45
|
-
| "rotate-scale-up"
|
|
46
|
-
| "rotate-scale-down"
|
|
47
|
-
| "rotate-scale-left"
|
|
48
|
-
| "rotate-scale-right"
|
|
49
|
-
| "rotate-scale-up-right"
|
|
50
|
-
| "rotate-scale-up-left"
|
|
51
|
-
| "rotate-scale-down-right"
|
|
52
|
-
| "rotate-scale-down-left"
|
|
53
|
-
| "zoom-in"
|
|
54
|
-
| "zoom-in-up"
|
|
55
|
-
| "zoom-in-down"
|
|
56
|
-
| "zoom-in-left"
|
|
57
|
-
| "zoom-in-right"
|
|
58
|
-
| "zoom-out"
|
|
59
|
-
| "zoom-out-up"
|
|
60
|
-
| "zoom-out-down"
|
|
61
|
-
| "zoom-out-left"
|
|
62
|
-
| "zoom-out-right";
|
|
63
|
-
|
|
64
|
-
// Anchor placements
|
|
65
|
-
export const ANCHOR_PLACEMENTS: AnchorOffsets = {
|
|
66
|
-
"top-bottom": { element: 0, viewport: 100 },
|
|
67
|
-
"top-center": { element: 0, viewport: 50 },
|
|
68
|
-
"top-top": { element: 0, viewport: 0 },
|
|
69
|
-
"center-bottom": { element: 50, viewport: 100 },
|
|
70
|
-
"center-center": { element: 50, viewport: 50 },
|
|
71
|
-
"center-top": { element: 50, viewport: 0 },
|
|
72
|
-
"bottom-bottom": { element: 100, viewport: 100 },
|
|
73
|
-
"bottom-center": { element: 100, viewport: 50 },
|
|
74
|
-
"bottom-top": { element: 100, viewport: 0 },
|
|
75
|
-
} as const;
|
|
76
|
-
|
|
77
|
-
export const ANIMATIONS: Record<string, AnimationConfig | undefined> = {
|
|
78
|
-
// Fade动画
|
|
79
|
-
fade: {
|
|
80
|
-
from: {
|
|
81
|
-
opacity: 0,
|
|
82
|
-
scale: 0.8,
|
|
83
|
-
},
|
|
84
|
-
duration: 1,
|
|
85
|
-
ease: "back.out(1.7)",
|
|
86
|
-
},
|
|
87
|
-
"fade-up": {
|
|
88
|
-
from: {
|
|
89
|
-
opacity: 0,
|
|
90
|
-
y: 160,
|
|
91
|
-
},
|
|
92
|
-
duration: 1.0,
|
|
93
|
-
ease: "power3.out",
|
|
94
|
-
},
|
|
95
|
-
"fade-down": {
|
|
96
|
-
from: {
|
|
97
|
-
opacity: 0,
|
|
98
|
-
y: -160,
|
|
99
|
-
},
|
|
100
|
-
duration: 1.0,
|
|
101
|
-
ease: "power3.out",
|
|
102
|
-
},
|
|
103
|
-
"fade-left": {
|
|
104
|
-
from: {
|
|
105
|
-
opacity: 0,
|
|
106
|
-
x: -160,
|
|
107
|
-
},
|
|
108
|
-
duration: 1.0,
|
|
109
|
-
ease: "power3.out",
|
|
110
|
-
},
|
|
111
|
-
"fade-right": {
|
|
112
|
-
from: {
|
|
113
|
-
opacity: 0,
|
|
114
|
-
x: 160,
|
|
115
|
-
},
|
|
116
|
-
duration: 1.0,
|
|
117
|
-
ease: "power3.out",
|
|
118
|
-
},
|
|
119
|
-
|
|
120
|
-
// Flip动画
|
|
121
|
-
flip: {
|
|
122
|
-
from: {
|
|
123
|
-
opacity: 0,
|
|
124
|
-
rotationY: 90,
|
|
125
|
-
transformPerspective: 1000,
|
|
126
|
-
},
|
|
127
|
-
duration: 1.0,
|
|
128
|
-
ease: "power3.out",
|
|
129
|
-
},
|
|
130
|
-
"flip-x": {
|
|
131
|
-
from: {
|
|
132
|
-
opacity: 0,
|
|
133
|
-
rotationX: 90,
|
|
134
|
-
transformPerspective: 1000,
|
|
135
|
-
},
|
|
136
|
-
duration: 1.0,
|
|
137
|
-
ease: "power3.out",
|
|
138
|
-
},
|
|
139
|
-
|
|
140
|
-
// Zoom动画
|
|
141
|
-
"zoom-in": {
|
|
142
|
-
from: {
|
|
143
|
-
opacity: 0,
|
|
144
|
-
scale: 0.6,
|
|
145
|
-
},
|
|
146
|
-
duration: 1.0,
|
|
147
|
-
ease: "power3.out",
|
|
148
|
-
},
|
|
149
|
-
"zoom-out": {
|
|
150
|
-
from: {
|
|
151
|
-
opacity: 0,
|
|
152
|
-
scale: 1.2,
|
|
153
|
-
},
|
|
154
|
-
duration: 1.0,
|
|
155
|
-
ease: "power3.out",
|
|
156
|
-
},
|
|
157
|
-
|
|
158
|
-
// 特殊效果
|
|
159
|
-
rotate: {
|
|
160
|
-
from: {
|
|
161
|
-
opacity: 0,
|
|
162
|
-
rotation: -90,
|
|
163
|
-
},
|
|
164
|
-
duration: 1.4,
|
|
165
|
-
ease: "back.out(1.4)",
|
|
166
|
-
},
|
|
167
|
-
"rotate-scale": {
|
|
168
|
-
from: {
|
|
169
|
-
opacity: 0,
|
|
170
|
-
rotation: -90,
|
|
171
|
-
scale: 0.85,
|
|
172
|
-
},
|
|
173
|
-
duration: 1.4,
|
|
174
|
-
ease: "back.out(1.4)",
|
|
175
|
-
},
|
|
176
|
-
};
|
|
177
|
-
|
|
178
|
-
export const AOS_ANIMATIONS: Record<string, AosAnimationConfig | undefined> = {
|
|
179
|
-
// Fade动画
|
|
180
|
-
fade: {
|
|
181
|
-
enter: {
|
|
182
|
-
from: { opacity: 0, scale: 0.8 },
|
|
183
|
-
duration: 1,
|
|
184
|
-
ease: "back.out(1.7)",
|
|
185
|
-
},
|
|
186
|
-
exit: {
|
|
187
|
-
to: { opacity: 0, scale: 0.8 },
|
|
188
|
-
duration: 0.8,
|
|
189
|
-
ease: "power3.in",
|
|
190
|
-
},
|
|
191
|
-
once: true,
|
|
192
|
-
},
|
|
193
|
-
"fade-up": {
|
|
194
|
-
enter: {
|
|
195
|
-
from: { opacity: 0, y: 160 },
|
|
196
|
-
duration: 1.0,
|
|
197
|
-
ease: "power3.out",
|
|
198
|
-
},
|
|
199
|
-
exit: {
|
|
200
|
-
to: { opacity: 0, y: 160 },
|
|
201
|
-
duration: 0.8,
|
|
202
|
-
ease: "power3.in",
|
|
203
|
-
},
|
|
204
|
-
threshold: 0.2,
|
|
205
|
-
once: true,
|
|
206
|
-
},
|
|
207
|
-
"fade-down": {
|
|
208
|
-
enter: {
|
|
209
|
-
from: { opacity: 0, y: -160 },
|
|
210
|
-
duration: 1.0,
|
|
211
|
-
ease: "power3.out",
|
|
212
|
-
},
|
|
213
|
-
exit: {
|
|
214
|
-
to: { opacity: 0, y: -160 },
|
|
215
|
-
duration: 0.8,
|
|
216
|
-
ease: "power3.in",
|
|
217
|
-
},
|
|
218
|
-
threshold: 0.2,
|
|
219
|
-
once: true,
|
|
220
|
-
},
|
|
221
|
-
"fade-left": {
|
|
222
|
-
enter: {
|
|
223
|
-
from: { opacity: 0, x: -160 },
|
|
224
|
-
duration: 1.0,
|
|
225
|
-
ease: "power3.out",
|
|
226
|
-
},
|
|
227
|
-
exit: {
|
|
228
|
-
to: { opacity: 0, x: -160 },
|
|
229
|
-
duration: 0.8,
|
|
230
|
-
ease: "power3.in",
|
|
231
|
-
},
|
|
232
|
-
threshold: 0.2,
|
|
233
|
-
once: true,
|
|
234
|
-
},
|
|
235
|
-
"fade-right": {
|
|
236
|
-
enter: {
|
|
237
|
-
from: { opacity: 0, x: 160 },
|
|
238
|
-
duration: 1.0,
|
|
239
|
-
ease: "power3.out",
|
|
240
|
-
},
|
|
241
|
-
exit: {
|
|
242
|
-
to: { opacity: 0, x: 160 },
|
|
243
|
-
duration: 0.8,
|
|
244
|
-
ease: "power3.in",
|
|
245
|
-
},
|
|
246
|
-
threshold: 0.2,
|
|
247
|
-
once: true,
|
|
248
|
-
},
|
|
249
|
-
|
|
250
|
-
// Flip动画
|
|
251
|
-
flip: {
|
|
252
|
-
enter: {
|
|
253
|
-
from: { opacity: 0, rotationY: 90, transformPerspective: 1000 },
|
|
254
|
-
duration: 1.0,
|
|
255
|
-
ease: "power3.out",
|
|
256
|
-
},
|
|
257
|
-
exit: {
|
|
258
|
-
to: { opacity: 0, rotationY: 90, transformPerspective: 1000 },
|
|
259
|
-
duration: 0.8,
|
|
260
|
-
ease: "power3.in",
|
|
261
|
-
},
|
|
262
|
-
threshold: 0.1,
|
|
263
|
-
once: true,
|
|
264
|
-
},
|
|
265
|
-
"flip-x": {
|
|
266
|
-
enter: {
|
|
267
|
-
from: { opacity: 0, rotationX: 90, transformPerspective: 1000 },
|
|
268
|
-
duration: 1.0,
|
|
269
|
-
ease: "power3.out",
|
|
270
|
-
},
|
|
271
|
-
exit: {
|
|
272
|
-
to: { opacity: 0, rotationX: 90, transformPerspective: 1000 },
|
|
273
|
-
duration: 0.8,
|
|
274
|
-
ease: "power3.in",
|
|
275
|
-
},
|
|
276
|
-
threshold: 0.1,
|
|
277
|
-
once: true,
|
|
278
|
-
},
|
|
279
|
-
|
|
280
|
-
// Zoom动画
|
|
281
|
-
"zoom-in": {
|
|
282
|
-
enter: {
|
|
283
|
-
from: { opacity: 0, scale: 0.6 },
|
|
284
|
-
duration: 1.0,
|
|
285
|
-
ease: "power3.out",
|
|
286
|
-
},
|
|
287
|
-
exit: {
|
|
288
|
-
to: { opacity: 0, scale: 0.6 },
|
|
289
|
-
duration: 0.8,
|
|
290
|
-
ease: "power3.in",
|
|
291
|
-
},
|
|
292
|
-
threshold: 0.2,
|
|
293
|
-
once: true,
|
|
294
|
-
},
|
|
295
|
-
"zoom-out": {
|
|
296
|
-
enter: {
|
|
297
|
-
from: { opacity: 0, scale: 1.2 },
|
|
298
|
-
duration: 1.0,
|
|
299
|
-
ease: "power3.out",
|
|
300
|
-
},
|
|
301
|
-
exit: {
|
|
302
|
-
to: { opacity: 0, scale: 1.2 },
|
|
303
|
-
duration: 0.8,
|
|
304
|
-
ease: "power3.in",
|
|
305
|
-
},
|
|
306
|
-
threshold: 0.2,
|
|
307
|
-
once: true,
|
|
308
|
-
},
|
|
309
|
-
|
|
310
|
-
// 特殊效果
|
|
311
|
-
rotate: {
|
|
312
|
-
enter: {
|
|
313
|
-
from: { opacity: 0, rotation: -90 },
|
|
314
|
-
duration: 1.4,
|
|
315
|
-
ease: "back.out(1.4)",
|
|
316
|
-
},
|
|
317
|
-
exit: {
|
|
318
|
-
to: { opacity: 0, rotation: 90 },
|
|
319
|
-
duration: 1.0,
|
|
320
|
-
ease: "power3.in",
|
|
321
|
-
},
|
|
322
|
-
threshold: 0.1,
|
|
323
|
-
once: true,
|
|
324
|
-
},
|
|
325
|
-
"rotate-scale": {
|
|
326
|
-
enter: {
|
|
327
|
-
from: { opacity: 0, rotation: -90, scale: 0.85 },
|
|
328
|
-
duration: 1.4,
|
|
329
|
-
ease: "back.out(1.4)",
|
|
330
|
-
},
|
|
331
|
-
exit: {
|
|
332
|
-
to: { opacity: 0, rotation: 90, scale: 0.85 },
|
|
333
|
-
duration: 1.0,
|
|
334
|
-
ease: "power3.in",
|
|
335
|
-
},
|
|
336
|
-
threshold: 0.1,
|
|
337
|
-
once: true,
|
|
338
|
-
},
|
|
339
|
-
};
|
|
340
|
-
|
|
341
|
-
export const POPUP_ANIMATIONS: Record<
|
|
342
|
-
string,
|
|
343
|
-
OpenableAnimationConfig | undefined
|
|
344
|
-
> = {
|
|
345
|
-
// 缩放效果
|
|
346
|
-
scale: {
|
|
347
|
-
open: {
|
|
348
|
-
from: { opacity: 0, scale: 0.5 },
|
|
349
|
-
duration: 0.4,
|
|
350
|
-
ease: "back.out(1.7)",
|
|
351
|
-
},
|
|
352
|
-
close: {
|
|
353
|
-
to: { opacity: 0, scale: 0.5 },
|
|
354
|
-
duration: 0.3,
|
|
355
|
-
ease: "power3.in",
|
|
356
|
-
},
|
|
357
|
-
},
|
|
358
|
-
|
|
359
|
-
// 淡入淡出
|
|
360
|
-
fade: {
|
|
361
|
-
open: {
|
|
362
|
-
from: { opacity: 0 },
|
|
363
|
-
duration: 0.3,
|
|
364
|
-
ease: "power2.out",
|
|
365
|
-
},
|
|
366
|
-
close: {
|
|
367
|
-
to: { opacity: 0 },
|
|
368
|
-
duration: 0.2,
|
|
369
|
-
ease: "power2.in",
|
|
370
|
-
},
|
|
371
|
-
},
|
|
372
|
-
|
|
373
|
-
// 从上方滑入
|
|
374
|
-
"slide-down": {
|
|
375
|
-
open: {
|
|
376
|
-
from: { opacity: 0, y: -50, scale: 0.98 },
|
|
377
|
-
duration: 0.4,
|
|
378
|
-
ease: "power3.out",
|
|
379
|
-
},
|
|
380
|
-
close: {
|
|
381
|
-
to: { opacity: 0, y: -50, scale: 0.98 },
|
|
382
|
-
duration: 0.3,
|
|
383
|
-
ease: "power2.in",
|
|
384
|
-
},
|
|
385
|
-
},
|
|
386
|
-
|
|
387
|
-
// 从下方滑入
|
|
388
|
-
"slide-up": {
|
|
389
|
-
open: {
|
|
390
|
-
from: { opacity: 0, y: 50, scale: 0.98 },
|
|
391
|
-
duration: 0.4,
|
|
392
|
-
ease: "power3.out",
|
|
393
|
-
},
|
|
394
|
-
close: {
|
|
395
|
-
to: { opacity: 0, y: 50, scale: 0.98 },
|
|
396
|
-
duration: 0.3,
|
|
397
|
-
ease: "power2.in",
|
|
398
|
-
},
|
|
399
|
-
},
|
|
400
|
-
|
|
401
|
-
// 从右侧滑入
|
|
402
|
-
"slide-left": {
|
|
403
|
-
open: {
|
|
404
|
-
from: { opacity: 0, x: 100 },
|
|
405
|
-
duration: 0.4,
|
|
406
|
-
ease: "power3.out",
|
|
407
|
-
},
|
|
408
|
-
close: {
|
|
409
|
-
to: { opacity: 0, x: 100 },
|
|
410
|
-
duration: 0.3,
|
|
411
|
-
ease: "power2.in",
|
|
412
|
-
},
|
|
413
|
-
},
|
|
414
|
-
|
|
415
|
-
// 从左侧滑入
|
|
416
|
-
"slide-right": {
|
|
417
|
-
open: {
|
|
418
|
-
from: { opacity: 0, x: -100 },
|
|
419
|
-
duration: 0.4,
|
|
420
|
-
ease: "power3.out",
|
|
421
|
-
},
|
|
422
|
-
close: {
|
|
423
|
-
to: { opacity: 0, x: -100 },
|
|
424
|
-
duration: 0.3,
|
|
425
|
-
ease: "power2.in",
|
|
426
|
-
},
|
|
427
|
-
},
|
|
428
|
-
};
|
|
@@ -1,102 +0,0 @@
|
|
|
1
|
-
import { AnimationConfig, EaseConfig, EaseString } from "./types";
|
|
2
|
-
import { gsap } from "gsap/dist/gsap";
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* 将AnimationConfig转换为GSAP兼容的TweenVars
|
|
6
|
-
* @param animation 动画配置
|
|
7
|
-
* @returns GSAP兼容的动画配置
|
|
8
|
-
*/
|
|
9
|
-
export function convertToGsapVars(animation: AnimationConfig): gsap.TweenVars {
|
|
10
|
-
// 创建基础TweenVars对象
|
|
11
|
-
const gsapVars: gsap.TweenVars = {};
|
|
12
|
-
|
|
13
|
-
// 如果传入的是直接包含属性的对象(如initial),直接使用其中的属性
|
|
14
|
-
if (
|
|
15
|
-
typeof animation === "object" &&
|
|
16
|
-
!animation.to &&
|
|
17
|
-
!animation.from &&
|
|
18
|
-
!animation.fromTo
|
|
19
|
-
) {
|
|
20
|
-
// 检查是否有initial属性
|
|
21
|
-
if (animation.initial) {
|
|
22
|
-
// initial属性是TweenVars类型,可以直接使用
|
|
23
|
-
Object.assign(gsapVars, animation.initial);
|
|
24
|
-
} else {
|
|
25
|
-
// 复制除了控制参数外的所有属性
|
|
26
|
-
// 这里使用安全的类型方式处理
|
|
27
|
-
const copyProps = (obj: Record<string, unknown>) => {
|
|
28
|
-
Object.keys(obj).forEach((key) => {
|
|
29
|
-
// 跳过动画控制参数
|
|
30
|
-
if (
|
|
31
|
-
key !== "duration" &&
|
|
32
|
-
key !== "delay" &&
|
|
33
|
-
key !== "ease" &&
|
|
34
|
-
key !== "preset"
|
|
35
|
-
) {
|
|
36
|
-
gsapVars[key] = obj[key];
|
|
37
|
-
}
|
|
38
|
-
});
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
copyProps(animation as Record<string, unknown>);
|
|
42
|
-
}
|
|
43
|
-
} else {
|
|
44
|
-
// 标准动画配置处理
|
|
45
|
-
// 复制所有属性
|
|
46
|
-
if (animation.to) {
|
|
47
|
-
Object.assign(gsapVars, animation.to);
|
|
48
|
-
}
|
|
49
|
-
|
|
50
|
-
if (animation.from) {
|
|
51
|
-
Object.assign(gsapVars, animation.from);
|
|
52
|
-
}
|
|
53
|
-
|
|
54
|
-
if (animation.fromTo) {
|
|
55
|
-
Object.assign(gsapVars, animation.fromTo.to);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
// 复制动画控制参数
|
|
60
|
-
if (animation.duration) gsapVars.duration = animation.duration;
|
|
61
|
-
if (animation.delay) gsapVars.delay = animation.delay;
|
|
62
|
-
|
|
63
|
-
// 处理ease属性
|
|
64
|
-
if (animation.ease) {
|
|
65
|
-
if (typeof animation.ease === "string") {
|
|
66
|
-
// 字符串直接使用
|
|
67
|
-
gsapVars.ease = animation.ease as EaseString;
|
|
68
|
-
} else if (typeof animation.ease === "function") {
|
|
69
|
-
// 如果是函数,直接使用
|
|
70
|
-
gsapVars.ease = animation.ease;
|
|
71
|
-
} else if (typeof animation.ease === "object" && "type" in animation.ease) {
|
|
72
|
-
// 处理EaseConfig对象
|
|
73
|
-
const easeConfig = animation.ease as EaseConfig;
|
|
74
|
-
if (easeConfig.type) {
|
|
75
|
-
// 将EaseConfig转换为字符串
|
|
76
|
-
let easeStr = easeConfig.type;
|
|
77
|
-
|
|
78
|
-
// 添加方向后缀,如.out
|
|
79
|
-
easeStr += ".out";
|
|
80
|
-
|
|
81
|
-
// 添加参数
|
|
82
|
-
if (easeConfig.config) {
|
|
83
|
-
const params = [];
|
|
84
|
-
if (easeConfig.config.overshoot !== undefined)
|
|
85
|
-
params.push(easeConfig.config.overshoot);
|
|
86
|
-
if (easeConfig.config.amplitude !== undefined)
|
|
87
|
-
params.push(easeConfig.config.amplitude);
|
|
88
|
-
if (easeConfig.config.period !== undefined)
|
|
89
|
-
params.push(easeConfig.config.period);
|
|
90
|
-
|
|
91
|
-
if (params.length > 0) {
|
|
92
|
-
easeStr += `(${params.join(",")})`;
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
gsapVars.ease = easeStr;
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
return gsapVars;
|
|
102
|
-
}
|
package/src/motion/index.ts
DELETED
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
import { ANIMATIONS } from "./consts";
|
|
2
|
-
import { AnimationConfig } from "./types";
|
|
3
|
-
import { merge } from "lodash-es";
|
|
4
|
-
|
|
5
|
-
/**
|
|
6
|
-
* 标准化动画配置,把预置动画补全
|
|
7
|
-
* @param motion 动画配置
|
|
8
|
-
* @param isDual 是否为双态动画
|
|
9
|
-
* @returns 标准化后的动画配置
|
|
10
|
-
*/
|
|
11
|
-
export function normalizeAnimation(motion?: AnimationConfig | string) {
|
|
12
|
-
let presetKey: string | undefined;
|
|
13
|
-
let normalMotion: AnimationConfig | undefined;
|
|
14
|
-
if (typeof motion === "string") {
|
|
15
|
-
presetKey = motion;
|
|
16
|
-
} else {
|
|
17
|
-
presetKey = motion?.preset;
|
|
18
|
-
normalMotion = motion;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
if (presetKey) {
|
|
22
|
-
const presetMotion = ANIMATIONS[presetKey];
|
|
23
|
-
if (presetMotion) {
|
|
24
|
-
return merge(presetMotion, normalMotion);
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
return normalMotion;
|
|
28
|
-
}
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import { merge } from "lodash-es";
|
|
2
|
-
import { AOS_ANIMATIONS } from "./consts";
|
|
3
|
-
import { AnimationConfig, AosAnimationConfig } from "./types";
|
|
4
|
-
|
|
5
|
-
export function normalizeAosAnimation(motion?: AosAnimationConfig | string) {
|
|
6
|
-
let presetKey: string | undefined;
|
|
7
|
-
let normalMotion: AnimationConfig | undefined;
|
|
8
|
-
if (typeof motion === "string") {
|
|
9
|
-
presetKey = motion;
|
|
10
|
-
} else {
|
|
11
|
-
presetKey = motion?.preset;
|
|
12
|
-
normalMotion = motion;
|
|
13
|
-
}
|
|
14
|
-
|
|
15
|
-
if (presetKey) {
|
|
16
|
-
const presetMotion = AOS_ANIMATIONS[presetKey];
|
|
17
|
-
if (presetMotion) {
|
|
18
|
-
return merge(presetMotion, normalMotion);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
return normalMotion;
|
|
22
|
-
}
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
import { merge } from "lodash-es";
|
|
2
|
-
import { OpenableAnimationConfig } from "./types";
|
|
3
|
-
import { POPUP_ANIMATIONS } from "./consts";
|
|
4
|
-
|
|
5
|
-
export function normalizePopupAnimation(
|
|
6
|
-
motion?: OpenableAnimationConfig | string
|
|
7
|
-
) {
|
|
8
|
-
let presetKey: string | undefined;
|
|
9
|
-
let normalMotion: OpenableAnimationConfig | undefined;
|
|
10
|
-
if (typeof motion === "string") {
|
|
11
|
-
presetKey = motion;
|
|
12
|
-
} else {
|
|
13
|
-
presetKey = motion?.preset;
|
|
14
|
-
normalMotion = motion;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
if (presetKey) {
|
|
18
|
-
const presetMotion = POPUP_ANIMATIONS[presetKey];
|
|
19
|
-
if (presetMotion) {
|
|
20
|
-
return merge(presetMotion, normalMotion);
|
|
21
|
-
}
|
|
22
|
-
}
|
|
23
|
-
return normalMotion;
|
|
24
|
-
}
|