@rxdrag/website-lib-core 0.0.7 → 0.0.9

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.
Files changed (71) hide show
  1. package/index.ts +1 -1
  2. package/package.json +11 -7
  3. package/src/component-logic/gsap.d.ts +4 -0
  4. package/src/component-logic/index.ts +8 -0
  5. package/src/component-logic/link-client.ts +33 -0
  6. package/src/component-logic/link.ts +50 -0
  7. package/src/component-logic/modal.ts +36 -0
  8. package/src/component-logic/motion.ts +272 -0
  9. package/src/component-logic/number.ts +45 -0
  10. package/src/component-logic/popover.ts +51 -0
  11. package/src/component-logic/tabs.ts +10 -0
  12. package/src/controller/AnimateController.ts +138 -0
  13. package/src/controller/AosController.ts +240 -0
  14. package/src/controller/FlipController.ts +339 -0
  15. package/src/controller/ModalController.ts +127 -0
  16. package/src/controller/NumberController.ts +161 -0
  17. package/src/controller/PageLoader.ts +153 -0
  18. package/src/controller/PopoverController.ts +116 -0
  19. package/src/controller/TabsController.ts +271 -0
  20. package/src/controller/applyAnimation.ts +86 -0
  21. package/src/controller/applyInitialState.ts +79 -0
  22. package/src/{scripts → controller}/consts.ts +0 -2
  23. package/src/controller/index.ts +9 -0
  24. package/src/controller/popup.ts +346 -0
  25. package/src/controller/utils.ts +48 -0
  26. package/src/entify/Entify.ts +354 -365
  27. package/src/entify/IEntify.ts +91 -0
  28. package/src/entify/index.ts +3 -2
  29. package/src/entify/lib/newQueryProductOptions.ts +2 -3
  30. package/src/entify/lib/newQueryProductsMediaOptions.ts +19 -18
  31. package/src/entify/lib/queryAllProducts.ts +11 -3
  32. package/src/entify/lib/queryFeaturedProducts.ts +3 -3
  33. package/src/entify/lib/queryLatestPosts.ts +2 -2
  34. package/src/entify/lib/queryOneTheme.ts +1 -1
  35. package/src/entify/lib/queryPostCategories.ts +3 -3
  36. package/src/entify/lib/queryPostSlugs.ts +2 -2
  37. package/src/entify/lib/queryPosts.ts +92 -92
  38. package/src/entify/lib/queryProductCategories.ts +3 -3
  39. package/src/entify/lib/queryProducts.ts +69 -69
  40. package/src/entify/lib/queryUserPosts.ts +2 -2
  41. package/src/entify/lib/searchProducts.ts +2 -2
  42. package/src/index.ts +3 -1
  43. package/src/lib/formatDate.ts +15 -0
  44. package/src/lib/index.ts +3 -0
  45. package/src/lib/pagination.ts +114 -0
  46. package/src/lib/utils.ts +119 -0
  47. package/src/motion/consts.ts +428 -598
  48. package/src/motion/convertToGsapVars.ts +102 -0
  49. package/src/motion/index.ts +5 -1
  50. package/src/motion/normalizeAnimation.ts +28 -0
  51. package/src/motion/normalizeAosAnimation.ts +22 -0
  52. package/src/motion/normalizePopupAnimation.ts +24 -0
  53. package/src/motion/types.ts +133 -46
  54. package/src/react/components/AttachmentIcon/index.tsx +53 -0
  55. package/src/react/components/ContactForm/index.tsx +341 -0
  56. package/src/react/components/Icon/index.tsx +10 -0
  57. package/src/react/components/Medias/index.tsx +347 -347
  58. package/src/react/components/ProductCard/ProductCta/index.tsx +7 -5
  59. package/src/react/components/RichTextOutline/index.tsx +76 -76
  60. package/src/react/components/Scroller.tsx +5 -1
  61. package/src/react/components/SearchInput.tsx +36 -34
  62. package/src/react/components/ToTop.tsx +63 -28
  63. package/src/react/components/index.ts +3 -1
  64. package/src/react/hooks/useScroll.ts +16 -10
  65. package/src/react/components/EnquiryForm/index.tsx +0 -334
  66. package/src/scripts/actions.ts +0 -304
  67. package/src/scripts/events.ts +0 -33
  68. package/src/scripts/index.ts +0 -3
  69. /package/src/react/components/{EnquiryForm → ContactForm}/Input.tsx +0 -0
  70. /package/src/react/components/{EnquiryForm → ContactForm}/Submit.tsx +0 -0
  71. /package/src/react/components/{EnquiryForm → ContactForm}/Textarea.tsx +0 -0
@@ -1,598 +1,428 @@
1
- import { AnchorOffsets, SimpleAnimation, DualAnimation } from "./types";
2
-
3
- // Easing functions
4
- export const EASINGS = {
5
- linear: [0, 0, 1, 1],
6
- ease: [0.25, 0.1, 0.25, 1],
7
- easeIn: [0.42, 0, 1, 1],
8
- easeOut: [0, 0, 0.58, 1],
9
- easeInOut: [0.42, 0, 0.58, 1],
10
- // Back
11
- easeInBack: [0.36, 0, 0.66, -0.56],
12
- easeOutBack: [0.34, 1.56, 0.64, 1],
13
- easeInOutBack: [0.68, -0.6, 0.32, 1.6],
14
- // Sine
15
- easeInSine: [0.12, 0, 0.39, 0],
16
- easeOutSine: [0.61, 1, 0.88, 1],
17
- easeInOutSine: [0.37, 0, 0.63, 1],
18
- // Quad
19
- easeInQuad: [0.11, 0, 0.5, 0],
20
- easeOutQuad: [0.5, 1, 0.89, 1],
21
- easeInOutQuad: [0.45, 0, 0.55, 1],
22
- // Cubic
23
- easeInCubic: [0.32, 0, 0.67, 0],
24
- easeOutCubic: [0.33, 1, 0.68, 1],
25
- easeInOutCubic: [0.65, 0, 0.35, 1],
26
- // Quart
27
- easeInQuart: [0.5, 0, 0.75, 0],
28
- easeOutQuart: [0.25, 1, 0.5, 1],
29
- easeInOutQuart: [0.76, 0, 0.24, 1],
30
- // 柔和的缓动函数
31
- softEaseOut: [0.16, 1, 0.3, 1], // 更加柔和
32
- softEaseInOut: [0.4, 0, 0.2, 1], // 后期更慢
33
- gentleEaseOut: [0.1, 0.9, 0.2, 1], // 非常柔和
34
- gentleBackOut: [0.2, 1.2, 0.5, 1], // 轻微弹性且柔和
35
- smoothEaseOut: [0.15, 0.85, 0.15, 1], // 平滑过渡
36
- ultraSmoothOut: [0.05, 0.9, 0.1, 1], // 极度平滑,后期非常慢
37
- microSmoothOut: [0.03, 0.94, 0.08, 1], // 微妙平滑,几乎无感知的减速
38
- silkEaseOut: [0.04, 0.88, 0.06, 0.98], // 丝绸般平滑,非常柔和的结束
39
- featherEaseOut: [0.08, 0.82, 0.17, 1], // 羽毛般轻盈,特别适合小幅度动画
40
- gentleSilkOut: [0.02, 0.9, 0.1, 0.99], // 极其柔和,几乎感觉不到停止
41
- ultraSlowOut: [0.02, 0.9, 0.05, 0.99], // 极度缓慢的结束
42
- silkSlowOut: [0.01, 0.85, 0.05, 0.95], // 丝绸般缓慢,后期极慢
43
- luxurySlowOut: [0.01, 0.8, 0.03, 0.92], // 奢华缓慢,几乎静止的结束
44
- } as const;
45
-
46
- //立即执行
47
- export const DATA_MOTION_ANIMATE = "data-motion-animate";
48
- //过渡
49
- //export const DATA_MOTION_TRANSITION = "data-motion-transition";
50
- //悬停
51
- export const DATA_MOTION_HOVER = "data-motion-hover";
52
- //按压
53
- export const DATA_MOTION_TAP = "data-motion-tap";
54
- //滚动
55
- export const DATA_MOTION_SCROLL = "data-motion-scroll";
56
- //入视图
57
- export const DATA_MOTION_INVIEW = "data-motion-inview";
58
- //打开动画,有动作的组件联动
59
- export const DATA_MOTION_OPEN = "data-motion-open";
60
- //关闭动画,有动作的组件联动
61
- export const DATA_MOTION_CLOSE = "data-motion-close";
62
-
63
- export enum ANIMATION {
64
- // Fade animations
65
- FADE = "fade",
66
- FADE_UP = "fade-up",
67
- FADE_DOWN = "fade-down",
68
- FADE_LEFT = "fade-left",
69
- FADE_RIGHT = "fade-right",
70
- FADE_UP_RIGHT = "fade-up-right",
71
- FADE_UP_LEFT = "fade-up-left",
72
- FADE_DOWN_RIGHT = "fade-down-right",
73
- FADE_DOWN_LEFT = "fade-down-left",
74
-
75
- // Flip animations
76
- FLIP_UP = "flip-up",
77
- FLIP_DOWN = "flip-down",
78
- FLIP_LEFT = "flip-left",
79
- FLIP_RIGHT = "flip-right",
80
-
81
- // Slide animations
82
- SLIDE_UP = "slide-up",
83
- SLIDE_DOWN = "slide-down",
84
- SLIDE_LEFT = "slide-left",
85
- SLIDE_RIGHT = "slide-right",
86
-
87
- // Zoom animations
88
- ZOOM_IN = "zoom-in",
89
- ZOOM_IN_UP = "zoom-in-up",
90
- ZOOM_IN_DOWN = "zoom-in-down",
91
- ZOOM_IN_LEFT = "zoom-in-left",
92
- ZOOM_IN_RIGHT = "zoom-in-right",
93
- ZOOM_OUT = "zoom-out",
94
- ZOOM_OUT_UP = "zoom-out-up",
95
- ZOOM_OUT_DOWN = "zoom-out-down",
96
- ZOOM_OUT_LEFT = "zoom-out-left",
97
- ZOOM_OUT_RIGHT = "zoom-out-right",
98
-
99
- // Special effects
100
- ROTATE = "rotate",
101
- ROTATE_SCALE = "rotate-scale",
102
- }
103
-
104
- // export enum ANCHOR_PLACEMENT {
105
- // TOP_BOTTOM = "top-bottom",
106
- // TOP_CENTER = "top-center",
107
- // TOP_TOP = "top-top",
108
- // CENTER_BOTTOM = "center-bottom",
109
- // CENTER_CENTER = "center-center",
110
- // CENTER_TOP = "center-top",
111
- // BOTTOM_BOTTOM = "bottom-bottom",
112
- // BOTTOM_CENTER = "bottom-center",
113
- // BOTTOM_TOP = "bottom-top",
114
- // }
115
-
116
- // export enum EASE {
117
- // // Basic
118
- // LINEAR = "linear",
119
- // EASE = "ease",
120
- // EASE_IN = "ease-in",
121
- // EASE_OUT = "ease-out",
122
- // EASE_IN_OUT = "ease-in-out",
123
-
124
- // // Back
125
- // EASE_IN_BACK = "ease-in-back",
126
- // EASE_OUT_BACK = "ease-out-back",
127
- // EASE_IN_OUT_BACK = "ease-in-out-back",
128
-
129
- // // Sine
130
- // EASE_IN_SINE = "ease-in-sine",
131
- // EASE_OUT_SINE = "ease-out-sine",
132
- // EASE_IN_OUT_SINE = "ease-in-out-sine",
133
-
134
- // // Quad
135
- // EASE_IN_QUAD = "ease-in-quad",
136
- // EASE_OUT_QUAD = "ease-out-quad",
137
- // EASE_IN_OUT_QUAD = "ease-in-out-quad",
138
-
139
- // // Cubic
140
- // EASE_IN_CUBIC = "ease-in-cubic",
141
- // EASE_OUT_CUBIC = "ease-out-cubic",
142
- // EASE_IN_OUT_CUBIC = "ease-in-out-cubic",
143
-
144
- // // Quart
145
- // EASE_IN_QUART = "ease-in-quart",
146
- // EASE_OUT_QUART = "ease-out-quart",
147
- // EASE_IN_OUT_QUART = "ease-in-out-quart",
148
- // }
149
-
150
- // Anchor placements
151
- export const ANCHOR_PLACEMENTS: AnchorOffsets = {
152
- "top-bottom": { element: 0, viewport: 100 },
153
- "top-center": { element: 0, viewport: 50 },
154
- "top-top": { element: 0, viewport: 0 },
155
- "center-bottom": { element: 50, viewport: 100 },
156
- "center-center": { element: 50, viewport: 50 },
157
- "center-top": { element: 50, viewport: 0 },
158
- "bottom-bottom": { element: 100, viewport: 100 },
159
- "bottom-center": { element: 100, viewport: 50 },
160
- "bottom-top": { element: 100, viewport: 0 },
161
- } as const;
162
-
163
- export const ANIMATIONS: Record<string, SimpleAnimation> = {
164
- // Fade animations
165
- fade: {
166
- keyframes: {
167
- opacity: [0, 1],
168
- scale: [0.8, 1],
169
- },
170
- transition: { duration: 1, ease: EASINGS.luxurySlowOut },
171
- },
172
- "fade-up": {
173
- keyframes: {
174
- opacity: [0, 1],
175
- transform: ["translateY(35px)", "translateY(0)"],
176
- },
177
- transition: { duration: 1.3, ease: EASINGS.silkSlowOut },
178
- },
179
- "fade-down": {
180
- keyframes: {
181
- opacity: [0, 1],
182
- transform: ["translateY(-35px)", "translateY(0)"],
183
- },
184
- transition: { duration: 1.3, ease: EASINGS.silkSlowOut },
185
- },
186
- "fade-left": {
187
- keyframes: {
188
- opacity: [0, 1],
189
- transform: ["translateX(35px)", "translateX(0)"],
190
- },
191
- transition: { duration: 1.3, ease: EASINGS.silkSlowOut },
192
- },
193
- "fade-right": {
194
- keyframes: {
195
- opacity: [0, 1],
196
- transform: ["translateX(-35px)", "translateX(0)"],
197
- },
198
- transition: { duration: 1.3, ease: EASINGS.silkSlowOut },
199
- },
200
- "fade-up-right": {
201
- keyframes: {
202
- opacity: [0, 1],
203
- transform: ["translate(-35px, 35px)", "translate(0, 0)"],
204
- },
205
- transition: { duration: 1.3, ease: EASINGS.silkSlowOut },
206
- },
207
- "fade-up-left": {
208
- keyframes: {
209
- opacity: [0, 1],
210
- transform: ["translate(35px, 35px)", "translate(0, 0)"],
211
- },
212
- transition: { duration: 1.3, ease: EASINGS.silkSlowOut },
213
- },
214
- "fade-down-right": {
215
- keyframes: {
216
- opacity: [0, 1],
217
- transform: ["translate(-35px, -35px)", "translate(0, 0)"],
218
- },
219
- transition: { duration: 1.3, ease: EASINGS.silkSlowOut },
220
- },
221
- "fade-down-left": {
222
- keyframes: {
223
- opacity: [0, 1],
224
- transform: ["translate(35px, -35px)", "translate(0, 0)"],
225
- },
226
- transition: { duration: 1.3, ease: EASINGS.silkSlowOut },
227
- },
228
-
229
- // Flip animations
230
- "flip-up": {
231
- keyframes: {
232
- transform: [
233
- "perspective(2500px) rotateX(60deg)",
234
- "perspective(2500px) rotateX(0)",
235
- ],
236
- opacity: [0, 1],
237
- },
238
- transition: { duration: 1.4, ease: EASINGS.luxurySlowOut },
239
- },
240
- "flip-down": {
241
- keyframes: {
242
- transform: [
243
- "perspective(2500px) rotateX(-60deg)",
244
- "perspective(2500px) rotateX(0)",
245
- ],
246
- opacity: [0, 1],
247
- },
248
- transition: { duration: 1.4, ease: EASINGS.luxurySlowOut },
249
- },
250
- "flip-left": {
251
- keyframes: {
252
- transform: [
253
- "perspective(2500px) rotateY(-60deg)",
254
- "perspective(2500px) rotateY(0)",
255
- ],
256
- opacity: [0, 1],
257
- },
258
- transition: { duration: 1.4, ease: EASINGS.luxurySlowOut },
259
- },
260
- "flip-right": {
261
- keyframes: {
262
- transform: [
263
- "perspective(2500px) rotateY(60deg)",
264
- "perspective(2500px) rotateY(0)",
265
- ],
266
- opacity: [0, 1],
267
- },
268
- transition: { duration: 1.4, ease: EASINGS.luxurySlowOut },
269
- },
270
-
271
- // Slide animations
272
- "slide-up": {
273
- keyframes: {
274
- transform: ["translateY(60%)", "translateY(0)"],
275
- },
276
- transition: { duration: 1.4, ease: EASINGS.ultraSlowOut },
277
- },
278
- "slide-down": {
279
- keyframes: {
280
- transform: ["translateY(-60%)", "translateY(0)"],
281
- },
282
- transition: { duration: 1.4, ease: EASINGS.ultraSlowOut },
283
- },
284
- "slide-left": {
285
- keyframes: {
286
- transform: ["translateX(60%)", "translateX(0)"],
287
- },
288
- transition: { duration: 1.4, ease: EASINGS.ultraSlowOut },
289
- },
290
- "slide-right": {
291
- keyframes: {
292
- transform: ["translateX(-60%)", "translateX(0)"],
293
- },
294
- transition: { duration: 1.4, ease: EASINGS.ultraSlowOut },
295
- },
296
-
297
- // Zoom animations
298
- "zoom-in": {
299
- keyframes: {
300
- transform: ["scale(0.85)", "scale(1)"],
301
- opacity: [0, 1],
302
- },
303
- transition: { duration: 1.2, ease: EASINGS.silkSlowOut },
304
- },
305
- "zoom-in-up": {
306
- keyframes: {
307
- transform: ["scale(0.85) translateY(30px)", "scale(1) translateY(0)"],
308
- opacity: [0, 1],
309
- },
310
- transition: { duration: 1.2, ease: EASINGS.silkSlowOut },
311
- },
312
- "zoom-in-down": {
313
- keyframes: {
314
- transform: ["scale(0.85) translateY(-30px)", "scale(1) translateY(0)"],
315
- opacity: [0, 1],
316
- },
317
- transition: { duration: 1.2, ease: EASINGS.silkSlowOut },
318
- },
319
- "zoom-in-left": {
320
- keyframes: {
321
- transform: ["scale(0.85) translateX(30px)", "scale(1) translateX(0)"],
322
- opacity: [0, 1],
323
- },
324
- transition: { duration: 1.2, ease: EASINGS.silkSlowOut },
325
- },
326
- "zoom-in-right": {
327
- keyframes: {
328
- transform: ["scale(0.85) translateX(-30px)", "scale(1) translateX(0)"],
329
- opacity: [0, 1],
330
- },
331
- transition: { duration: 1.2, ease: EASINGS.silkSlowOut },
332
- },
333
- "zoom-out": {
334
- keyframes: {
335
- transform: ["scale(1.15)", "scale(1)"],
336
- opacity: [0, 1],
337
- },
338
- transition: { duration: 1.2, ease: EASINGS.silkSlowOut },
339
- },
340
- "zoom-out-up": {
341
- keyframes: {
342
- transform: ["scale(1.15) translateY(30px)", "scale(1) translateY(0)"],
343
- opacity: [0, 1],
344
- },
345
- transition: { duration: 1.2, ease: EASINGS.silkSlowOut },
346
- },
347
- "zoom-out-down": {
348
- keyframes: {
349
- transform: ["scale(1.15) translateY(-30px)", "scale(1) translateY(0)"],
350
- opacity: [0, 1],
351
- },
352
- transition: { duration: 1.2, ease: EASINGS.silkSlowOut },
353
- },
354
- "zoom-out-left": {
355
- keyframes: {
356
- transform: ["scale(1.15) translateX(30px)", "scale(1) translateX(0)"],
357
- opacity: [0, 1],
358
- },
359
- transition: { duration: 1.2, ease: EASINGS.silkSlowOut },
360
- },
361
- "zoom-out-right": {
362
- keyframes: {
363
- transform: ["scale(1.15) translateX(-30px)", "scale(1) translateX(0)"],
364
- opacity: [0, 1],
365
- },
366
- transition: { duration: 1.2, ease: EASINGS.silkSlowOut },
367
- },
368
-
369
- // Special effects
370
- rotate: {
371
- keyframes: {
372
- transform: ["rotate(-90deg)", "rotate(0)"],
373
- opacity: [0, 1],
374
- },
375
- transition: { duration: 1.4, ease: EASINGS.luxurySlowOut },
376
- },
377
- "rotate-scale": {
378
- keyframes: {
379
- transform: ["rotate(-90deg) scale(0.85)", "rotate(0) scale(1)"],
380
- opacity: [0, 1],
381
- },
382
- transition: { duration: 1.4, ease: EASINGS.luxurySlowOut },
383
- },
384
- };
385
-
386
- export const DUAL_ANIMATIONS: Record<string, DualAnimation> = {
387
- // Fade animations
388
- fade: {
389
- in: ANIMATIONS.fade,
390
- out: {
391
- keyframes: {
392
- opacity: [1, 0],
393
- scale: [1, 0.98],
394
- },
395
- transition: { duration: 1, ease: EASINGS.luxurySlowOut },
396
- },
397
- },
398
- "fade-up": {
399
- in: ANIMATIONS["fade-up"],
400
- out: {
401
- keyframes: { opacity: [1, 0], y: [0, -35] },
402
- transition: { duration: 1, ease: EASINGS.silkSlowOut },
403
- },
404
- },
405
- "fade-down": {
406
- in: ANIMATIONS["fade-down"],
407
- out: {
408
- keyframes: { opacity: [1, 0], y: [0, 35] },
409
- transition: { duration: 1, ease: EASINGS.silkSlowOut },
410
- },
411
- },
412
- "fade-left": {
413
- in: ANIMATIONS["fade-left"],
414
- out: {
415
- keyframes: { opacity: [1, 0], x: [0, -35] },
416
- transition: { duration: 1, ease: EASINGS.silkSlowOut },
417
- },
418
- },
419
- "fade-right": {
420
- in: ANIMATIONS["fade-right"],
421
- out: {
422
- keyframes: { opacity: [1, 0], x: [0, 35] },
423
- transition: { duration: 1, ease: EASINGS.silkSlowOut },
424
- },
425
- },
426
- "fade-up-right": {
427
- in: ANIMATIONS["fade-up-right"],
428
- out: {
429
- keyframes: { opacity: [1, 0], x: [0, 35], y: [0, -35] },
430
- transition: { duration: 1, ease: EASINGS.silkSlowOut },
431
- },
432
- },
433
- "fade-up-left": {
434
- in: ANIMATIONS["fade-up-left"],
435
- out: {
436
- keyframes: { opacity: [1, 0], x: [0, -35], y: [0, -35] },
437
- transition: { duration: 1, ease: EASINGS.silkSlowOut },
438
- },
439
- },
440
- "fade-down-right": {
441
- in: ANIMATIONS["fade-down-right"],
442
- out: {
443
- keyframes: { opacity: [1, 0], x: [0, 35], y: [0, 35] },
444
- transition: { duration: 1, ease: EASINGS.silkSlowOut },
445
- },
446
- },
447
- "fade-down-left": {
448
- in: ANIMATIONS["fade-down-left"],
449
- out: {
450
- keyframes: { opacity: [1, 0], x: [0, -35], y: [0, 35] },
451
- transition: { duration: 1, ease: EASINGS.silkSlowOut },
452
- },
453
- },
454
- // Flip animations
455
- "flip-up": {
456
- in: ANIMATIONS["flip-up"],
457
- out: {
458
- keyframes: { rotateX: [0, 60], opacity: [1, 0] },
459
- transition: { duration: 1, ease: EASINGS.luxurySlowOut },
460
- },
461
- },
462
- "flip-down": {
463
- in: ANIMATIONS["flip-down"],
464
- out: {
465
- keyframes: { rotateX: [0, -60], opacity: [1, 0] },
466
- transition: { duration: 1, ease: EASINGS.luxurySlowOut },
467
- },
468
- },
469
- "flip-left": {
470
- in: ANIMATIONS["flip-left"],
471
- out: {
472
- keyframes: { rotateY: [0, -60], opacity: [1, 0] },
473
- transition: { duration: 1, ease: EASINGS.luxurySlowOut },
474
- },
475
- },
476
- "flip-right": {
477
- in: ANIMATIONS["flip-right"],
478
- out: {
479
- keyframes: { rotateY: [0, 60], opacity: [1, 0] },
480
- transition: { duration: 1, ease: EASINGS.luxurySlowOut },
481
- },
482
- },
483
- // Slide animations
484
- "slide-up": {
485
- in: ANIMATIONS["slide-up"],
486
- out: {
487
- keyframes: { y: [0, -60] },
488
- transition: { duration: 1, ease: EASINGS.ultraSlowOut },
489
- },
490
- },
491
- "slide-down": {
492
- in: ANIMATIONS["slide-down"],
493
- out: {
494
- keyframes: { y: [0, 60] },
495
- transition: { duration: 1, ease: EASINGS.ultraSlowOut },
496
- },
497
- },
498
- "slide-left": {
499
- in: ANIMATIONS["slide-left"],
500
- out: {
501
- keyframes: { x: [0, -60] },
502
- transition: { duration: 1, ease: EASINGS.ultraSlowOut },
503
- },
504
- },
505
- "slide-right": {
506
- in: ANIMATIONS["slide-right"],
507
- out: {
508
- keyframes: { x: [0, 60] },
509
- transition: { duration: 1, ease: EASINGS.ultraSlowOut },
510
- },
511
- },
512
- // Zoom animations
513
- "zoom-in": {
514
- in: ANIMATIONS["zoom-in"],
515
- out: {
516
- keyframes: { scale: [1, 0.85], opacity: [1, 0] },
517
- transition: { duration: 1, ease: EASINGS.silkSlowOut },
518
- },
519
- },
520
- "zoom-in-up": {
521
- in: ANIMATIONS["zoom-in-up"],
522
- out: {
523
- keyframes: { scale: [1, 0.85], y: [0, -30], opacity: [1, 0] },
524
- transition: { duration: 1, ease: EASINGS.silkSlowOut },
525
- },
526
- },
527
- "zoom-in-down": {
528
- in: ANIMATIONS["zoom-in-down"],
529
- out: {
530
- keyframes: { scale: [1, 0.85], y: [0, 30], opacity: [1, 0] },
531
- transition: { duration: 1, ease: EASINGS.silkSlowOut },
532
- },
533
- },
534
- "zoom-in-left": {
535
- in: ANIMATIONS["zoom-in-left"],
536
- out: {
537
- keyframes: { scale: [1, 0.85], x: [0, -30], opacity: [1, 0] },
538
- transition: { duration: 1, ease: EASINGS.silkSlowOut },
539
- },
540
- },
541
- "zoom-in-right": {
542
- in: ANIMATIONS["zoom-in-right"],
543
- out: {
544
- keyframes: { scale: [1, 0.85], x: [0, 30], opacity: [1, 0] },
545
- transition: { duration: 1, ease: EASINGS.silkSlowOut },
546
- },
547
- },
548
- "zoom-out": {
549
- in: ANIMATIONS["zoom-out"],
550
- out: {
551
- keyframes: { scale: [1, 1.15], opacity: [1, 0] },
552
- transition: { duration: 1, ease: EASINGS.silkSlowOut },
553
- },
554
- },
555
- "zoom-out-up": {
556
- in: ANIMATIONS["zoom-out-up"],
557
- out: {
558
- keyframes: { scale: [1, 1.15], y: [0, -30], opacity: [1, 0] },
559
- transition: { duration: 1, ease: EASINGS.silkSlowOut },
560
- },
561
- },
562
- "zoom-out-down": {
563
- in: ANIMATIONS["zoom-out-down"],
564
- out: {
565
- keyframes: { scale: [1, 1.15], y: [0, 30], opacity: [1, 0] },
566
- transition: { duration: 1, ease: EASINGS.silkSlowOut },
567
- },
568
- },
569
- "zoom-out-left": {
570
- in: ANIMATIONS["zoom-out-left"],
571
- out: {
572
- keyframes: { scale: [1, 1.15], x: [0, -30], opacity: [1, 0] },
573
- transition: { duration: 1, ease: EASINGS.silkSlowOut },
574
- },
575
- },
576
- "zoom-out-right": {
577
- in: ANIMATIONS["zoom-out-right"],
578
- out: {
579
- keyframes: { scale: [1, 1.15], x: [0, 30], opacity: [1, 0] },
580
- transition: { duration: 1, ease: EASINGS.silkSlowOut },
581
- },
582
- },
583
- // Special effects
584
- rotate: {
585
- in: ANIMATIONS.rotate,
586
- out: {
587
- keyframes: { rotate: [0, 90], opacity: [1, 0] },
588
- transition: { duration: 1, ease: EASINGS.luxurySlowOut },
589
- },
590
- },
591
- "rotate-scale": {
592
- in: ANIMATIONS["rotate-scale"],
593
- out: {
594
- keyframes: { rotate: [0, 90], scale: [1, 0.85], opacity: [1, 0] },
595
- transition: { duration: 1, ease: EASINGS.luxurySlowOut },
596
- },
597
- },
598
- };
1
+ import {
2
+ AnchorOffsets,
3
+ AosAnimationConfig,
4
+ PopupAnimationConfig,
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_POPUP = "data-motion-popup";
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
+ PopupAnimationConfig | 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
+ };