@readdy/anim 0.0.21

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 (310) hide show
  1. package/animations/button/3d-flip/index.js +60 -0
  2. package/animations/button/3d-flip/react.tsx +29 -0
  3. package/animations/button/3d-flip/style.css +17 -0
  4. package/animations/button/blur-fade-in/index.js +21 -0
  5. package/animations/button/blur-fade-in/react.tsx +26 -0
  6. package/animations/button/blur-fade-in/style.css +27 -0
  7. package/animations/button/border-beam/index.js +172 -0
  8. package/animations/button/border-beam/react.tsx +55 -0
  9. package/animations/button/border-beam/style.css +59 -0
  10. package/animations/button/bounce-elastic/index.js +21 -0
  11. package/animations/button/bounce-elastic/react.tsx +26 -0
  12. package/animations/button/bounce-elastic/style.css +31 -0
  13. package/animations/button/bubble-button/index.js +317 -0
  14. package/animations/button/bubble-button/react.tsx +19 -0
  15. package/animations/button/bubble-button/style.css +245 -0
  16. package/animations/button/confetti-button/index.js +66 -0
  17. package/animations/button/confetti-button/react.tsx +30 -0
  18. package/animations/button/confetti-button/style.css +48 -0
  19. package/animations/button/glow-cta/index.js +69 -0
  20. package/animations/button/glow-cta/react.tsx +45 -0
  21. package/animations/button/glow-cta/style.css +78 -0
  22. package/animations/button/magnetic-hover/index.js +61 -0
  23. package/animations/button/magnetic-hover/react.tsx +29 -0
  24. package/animations/button/magnetic-hover/style.css +18 -0
  25. package/animations/button/pulse/index.js +21 -0
  26. package/animations/button/pulse/react.tsx +26 -0
  27. package/animations/button/pulse/style.css +24 -0
  28. package/animations/button/rainbow-button/index.js +21 -0
  29. package/animations/button/rainbow-button/react.tsx +26 -0
  30. package/animations/button/rainbow-button/style.css +54 -0
  31. package/animations/button/shimmer-border/index.js +28 -0
  32. package/animations/button/shimmer-border/react.tsx +41 -0
  33. package/animations/button/shimmer-border/style.css +53 -0
  34. package/animations/button/sketch-button/index.js +16 -0
  35. package/animations/button/sketch-button/react.tsx +19 -0
  36. package/animations/button/sketch-button/style.css +25 -0
  37. package/animations/card/blur-rise/index.js +21 -0
  38. package/animations/card/blur-rise/react.tsx +26 -0
  39. package/animations/card/blur-rise/style.css +27 -0
  40. package/animations/card/bounce-in-bottom/index.js +21 -0
  41. package/animations/card/bounce-in-bottom/react.tsx +26 -0
  42. package/animations/card/bounce-in-bottom/style.css +31 -0
  43. package/animations/card/card-fan-spread/index.js +146 -0
  44. package/animations/card/card-fan-spread/react.tsx +35 -0
  45. package/animations/card/card-fan-spread/style.css +90 -0
  46. package/animations/card/card-flip/index.js +203 -0
  47. package/animations/card/card-flip/react.tsx +35 -0
  48. package/animations/card/card-flip/style.css +71 -0
  49. package/animations/card/float-idle/index.js +21 -0
  50. package/animations/card/float-idle/react.tsx +26 -0
  51. package/animations/card/float-idle/style.css +21 -0
  52. package/animations/card/image-magnifier/index.js +333 -0
  53. package/animations/card/image-magnifier/react.tsx +31 -0
  54. package/animations/card/image-magnifier/style.css +42 -0
  55. package/animations/card/image-zoom-rotate/index.js +48 -0
  56. package/animations/card/image-zoom-rotate/react.tsx +31 -0
  57. package/animations/card/image-zoom-rotate/style.css +20 -0
  58. package/animations/card/pop-in-stack/index.js +25 -0
  59. package/animations/card/pop-in-stack/react.tsx +33 -0
  60. package/animations/card/pop-in-stack/style.css +25 -0
  61. package/animations/card/reveal-from-top/index.js +21 -0
  62. package/animations/card/reveal-from-top/react.tsx +26 -0
  63. package/animations/card/reveal-from-top/style.css +28 -0
  64. package/animations/card/rgb-split-glitch/index.js +28 -0
  65. package/animations/card/rgb-split-glitch/react.tsx +41 -0
  66. package/animations/card/rgb-split-glitch/style.css +33 -0
  67. package/animations/card/tilted-card/index.js +64 -0
  68. package/animations/card/tilted-card/react.tsx +33 -0
  69. package/animations/card/tilted-card/style.css +27 -0
  70. package/animations/header/anime-splittext/index.js +108 -0
  71. package/animations/header/anime-splittext/react.tsx +30 -0
  72. package/animations/header/anime-splittext/style.css +71 -0
  73. package/animations/header/bounce-in-down/index.js +40 -0
  74. package/animations/header/bounce-in-down/react.tsx +29 -0
  75. package/animations/header/bounce-in-down/style.css +40 -0
  76. package/animations/header/fly-in-chars/index.js +46 -0
  77. package/animations/header/fly-in-chars/react.tsx +30 -0
  78. package/animations/header/fly-in-chars/style.css +29 -0
  79. package/animations/header/gradient-text/index.js +21 -0
  80. package/animations/header/gradient-text/react.tsx +26 -0
  81. package/animations/header/gradient-text/style.css +28 -0
  82. package/animations/header/letter-bounce/index.js +33 -0
  83. package/animations/header/letter-bounce/react.tsx +34 -0
  84. package/animations/header/letter-bounce/style.css +25 -0
  85. package/animations/header/roll-in/index.js +40 -0
  86. package/animations/header/roll-in/react.tsx +29 -0
  87. package/animations/header/roll-in/style.css +31 -0
  88. package/animations/header/shimmer-text/index.js +16 -0
  89. package/animations/header/shimmer-text/react.tsx +28 -0
  90. package/animations/header/shimmer-text/style.css +29 -0
  91. package/animations/header/shuffle/index.js +118 -0
  92. package/animations/header/shuffle/react.tsx +50 -0
  93. package/animations/header/shuffle/style.css +25 -0
  94. package/animations/header/split-text/index.js +72 -0
  95. package/animations/header/split-text/react.tsx +38 -0
  96. package/animations/header/split-text/style.css +31 -0
  97. package/animations/header/text-type/index.js +267 -0
  98. package/animations/header/text-type/react.tsx +63 -0
  99. package/animations/header/text-type/style.css +37 -0
  100. package/animations/header/word-curtain-reveal/index.js +97 -0
  101. package/animations/header/word-curtain-reveal/react.tsx +30 -0
  102. package/animations/header/word-curtain-reveal/style.css +39 -0
  103. package/dist/button/3d-flip/react.js +21 -0
  104. package/dist/button/3d-flip.js +61 -0
  105. package/dist/button/blur-fade-in/react.js +28 -0
  106. package/dist/button/blur-fade-in.js +17 -0
  107. package/dist/button/border-beam/react.js +22 -0
  108. package/dist/button/border-beam.js +168 -0
  109. package/dist/button/bounce-elastic/react.js +28 -0
  110. package/dist/button/bounce-elastic.js +17 -0
  111. package/dist/button/bubble-button/react.js +20 -0
  112. package/dist/button/bubble-button.js +318 -0
  113. package/dist/button/confetti-button/react.js +21 -0
  114. package/dist/button/confetti-button.js +67 -0
  115. package/dist/button/glow-cta/react.js +23 -0
  116. package/dist/button/glow-cta.js +65 -0
  117. package/dist/button/magnetic-hover/react.js +21 -0
  118. package/dist/button/magnetic-hover.js +62 -0
  119. package/dist/button/pulse/react.js +28 -0
  120. package/dist/button/pulse.js +17 -0
  121. package/dist/button/rainbow-button/react.js +28 -0
  122. package/dist/button/rainbow-button.js +17 -0
  123. package/dist/button/shimmer-border/react.js +22 -0
  124. package/dist/button/shimmer-border.js +24 -0
  125. package/dist/button/sketch-button/react.js +20 -0
  126. package/dist/button/sketch-button.js +17 -0
  127. package/dist/card/blur-rise/react.js +28 -0
  128. package/dist/card/blur-rise.js +17 -0
  129. package/dist/card/bounce-in-bottom/react.js +28 -0
  130. package/dist/card/bounce-in-bottom.js +17 -0
  131. package/dist/card/card-fan-spread/react.js +20 -0
  132. package/dist/card/card-fan-spread.js +147 -0
  133. package/dist/card/float-idle/react.js +28 -0
  134. package/dist/card/float-idle.js +17 -0
  135. package/dist/card/image-magnifier/react.js +22 -0
  136. package/dist/card/image-magnifier.js +334 -0
  137. package/dist/card/image-zoom-rotate/react.js +21 -0
  138. package/dist/card/image-zoom-rotate.js +49 -0
  139. package/dist/card/pop-in-stack/react.js +20 -0
  140. package/dist/card/pop-in-stack.js +26 -0
  141. package/dist/card/reveal-from-top/react.js +28 -0
  142. package/dist/card/reveal-from-top.js +17 -0
  143. package/dist/card/rgb-split-glitch/react.js +22 -0
  144. package/dist/card/rgb-split-glitch.js +24 -0
  145. package/dist/card/tilted-card/react.js +21 -0
  146. package/dist/card/tilted-card.js +65 -0
  147. package/dist/chunks/constants-EnH6-Pz4.js +66 -0
  148. package/dist/chunks/constants-ZTHic1pf.js +66 -0
  149. package/dist/chunks/pointer-follow-B3RFnn_q.js +93 -0
  150. package/dist/chunks/pointer-follow-BETANySn.js +93 -0
  151. package/dist/chunks/reduced-motion-BpQYuEzK.js +17 -0
  152. package/dist/chunks/reduced-motion-HX79Ac8G.js +17 -0
  153. package/dist/chunks/resolve-card-media-Cj3V_oms.js +43 -0
  154. package/dist/chunks/resolve-card-media-DBIU-duL.js +43 -0
  155. package/dist/chunks/text-split-D02jltVh.js +191 -0
  156. package/dist/chunks/text-split-frOR4UpH.js +191 -0
  157. package/dist/full.css +1 -0
  158. package/dist/full.js +3192 -0
  159. package/dist/header/anime-splittext/react.js +22 -0
  160. package/dist/header/anime-splittext.js +109 -0
  161. package/dist/header/bounce-in-down/react.js +32 -0
  162. package/dist/header/bounce-in-down.js +36 -0
  163. package/dist/header/fly-in-chars/react.js +23 -0
  164. package/dist/header/fly-in-chars.js +47 -0
  165. package/dist/header/gradient-text/react.js +28 -0
  166. package/dist/header/gradient-text.js +17 -0
  167. package/dist/header/letter-bounce/react.js +23 -0
  168. package/dist/header/letter-bounce.js +34 -0
  169. package/dist/header/roll-in/react.js +32 -0
  170. package/dist/header/roll-in.js +36 -0
  171. package/dist/header/shimmer-text/react.js +27 -0
  172. package/dist/header/shimmer-text.js +17 -0
  173. package/dist/header/shuffle/react.js +30 -0
  174. package/dist/header/shuffle.js +119 -0
  175. package/dist/header/split-text/react.js +26 -0
  176. package/dist/header/split-text.js +73 -0
  177. package/dist/header/text-type/react.js +43 -0
  178. package/dist/header/text-type.js +268 -0
  179. package/dist/header/word-curtain-reveal/react.js +22 -0
  180. package/dist/header/word-curtain-reveal.js +98 -0
  181. package/dist/meta.json +6 -0
  182. package/dist/metadata.json +1051 -0
  183. package/dist/react.css +1 -0
  184. package/dist/types/animations/button/3d-flip/index.d.ts +3 -0
  185. package/dist/types/animations/button/3d-flip/react.d.ts +8 -0
  186. package/dist/types/animations/button/blur-fade-in/index.d.ts +3 -0
  187. package/dist/types/animations/button/blur-fade-in/react.d.ts +13 -0
  188. package/dist/types/animations/button/border-beam/index.d.ts +3 -0
  189. package/dist/types/animations/button/border-beam/react.d.ts +25 -0
  190. package/dist/types/animations/button/bounce-elastic/index.d.ts +3 -0
  191. package/dist/types/animations/button/bounce-elastic/react.d.ts +13 -0
  192. package/dist/types/animations/button/bubble-button/index.d.ts +3 -0
  193. package/dist/types/animations/button/bubble-button/react.d.ts +4 -0
  194. package/dist/types/animations/button/confetti-button/index.d.ts +3 -0
  195. package/dist/types/animations/button/confetti-button/react.d.ts +8 -0
  196. package/dist/types/animations/button/glow-cta/index.d.ts +3 -0
  197. package/dist/types/animations/button/glow-cta/react.d.ts +20 -0
  198. package/dist/types/animations/button/magnetic-hover/index.d.ts +3 -0
  199. package/dist/types/animations/button/magnetic-hover/react.d.ts +8 -0
  200. package/dist/types/animations/button/pulse/index.d.ts +3 -0
  201. package/dist/types/animations/button/pulse/react.d.ts +13 -0
  202. package/dist/types/animations/button/rainbow-button/index.d.ts +3 -0
  203. package/dist/types/animations/button/rainbow-button/react.d.ts +13 -0
  204. package/dist/types/animations/button/shimmer-border/index.d.ts +3 -0
  205. package/dist/types/animations/button/shimmer-border/react.d.ts +18 -0
  206. package/dist/types/animations/button/sketch-button/index.d.ts +3 -0
  207. package/dist/types/animations/button/sketch-button/react.d.ts +4 -0
  208. package/dist/types/animations/card/blur-rise/index.d.ts +3 -0
  209. package/dist/types/animations/card/blur-rise/react.d.ts +13 -0
  210. package/dist/types/animations/card/bounce-in-bottom/index.d.ts +3 -0
  211. package/dist/types/animations/card/bounce-in-bottom/react.d.ts +13 -0
  212. package/dist/types/animations/card/card-fan-spread/index.d.ts +3 -0
  213. package/dist/types/animations/card/card-fan-spread/react.d.ts +11 -0
  214. package/dist/types/animations/card/card-flip/index.d.ts +3 -0
  215. package/dist/types/animations/card/card-flip/react.d.ts +11 -0
  216. package/dist/types/animations/card/float-idle/index.d.ts +3 -0
  217. package/dist/types/animations/card/float-idle/react.d.ts +13 -0
  218. package/dist/types/animations/card/image-magnifier/index.d.ts +3 -0
  219. package/dist/types/animations/card/image-magnifier/react.d.ts +9 -0
  220. package/dist/types/animations/card/image-zoom-rotate/index.d.ts +3 -0
  221. package/dist/types/animations/card/image-zoom-rotate/react.d.ts +9 -0
  222. package/dist/types/animations/card/pop-in-stack/index.d.ts +3 -0
  223. package/dist/types/animations/card/pop-in-stack/react.d.ts +10 -0
  224. package/dist/types/animations/card/reveal-from-top/index.d.ts +3 -0
  225. package/dist/types/animations/card/reveal-from-top/react.d.ts +13 -0
  226. package/dist/types/animations/card/rgb-split-glitch/index.d.ts +3 -0
  227. package/dist/types/animations/card/rgb-split-glitch/react.d.ts +18 -0
  228. package/dist/types/animations/card/tilted-card/index.d.ts +3 -0
  229. package/dist/types/animations/card/tilted-card/react.d.ts +10 -0
  230. package/dist/types/animations/header/anime-splittext/index.d.ts +3 -0
  231. package/dist/types/animations/header/anime-splittext/react.d.ts +8 -0
  232. package/dist/types/animations/header/bounce-in-down/index.d.ts +3 -0
  233. package/dist/types/animations/header/bounce-in-down/react.d.ts +13 -0
  234. package/dist/types/animations/header/fly-in-chars/index.d.ts +3 -0
  235. package/dist/types/animations/header/fly-in-chars/react.d.ts +8 -0
  236. package/dist/types/animations/header/gradient-text/index.d.ts +3 -0
  237. package/dist/types/animations/header/gradient-text/react.d.ts +13 -0
  238. package/dist/types/animations/header/letter-bounce/index.d.ts +3 -0
  239. package/dist/types/animations/header/letter-bounce/react.d.ts +10 -0
  240. package/dist/types/animations/header/roll-in/index.d.ts +3 -0
  241. package/dist/types/animations/header/roll-in/react.d.ts +13 -0
  242. package/dist/types/animations/header/shimmer-text/index.d.ts +3 -0
  243. package/dist/types/animations/header/shimmer-text/react.d.ts +4 -0
  244. package/dist/types/animations/header/shuffle/index.d.ts +3 -0
  245. package/dist/types/animations/header/shuffle/react.d.ts +14 -0
  246. package/dist/types/animations/header/split-text/index.d.ts +3 -0
  247. package/dist/types/animations/header/split-text/react.d.ts +10 -0
  248. package/dist/types/animations/header/text-type/index.d.ts +3 -0
  249. package/dist/types/animations/header/text-type/react.d.ts +13 -0
  250. package/dist/types/animations/header/word-curtain-reveal/index.d.ts +3 -0
  251. package/dist/types/animations/header/word-curtain-reveal/react.d.ts +8 -0
  252. package/dist/types/react-barrel.d.ts +34 -0
  253. package/dist/types/scripts/bundle-all.d.ts +173 -0
  254. package/dist/types/scripts/check-metadata.d.ts +1 -0
  255. package/dist/types/scripts/copy-metadata.d.ts +1 -0
  256. package/dist/types/scripts/generate-animation-id-map.d.ts +1 -0
  257. package/dist/types/scripts/generate-dist-meta.d.ts +1 -0
  258. package/dist/types/scripts/generate-preview-manifest.d.ts +1 -0
  259. package/dist/types/scripts/update-metadata.d.ts +1 -0
  260. package/dist/types/shared/constants.d.ts +34 -0
  261. package/dist/types/shared/meta.d.ts +18 -0
  262. package/dist/types/shared/pointer-follow.d.ts +8 -0
  263. package/dist/types/shared/reduced-motion.d.ts +11 -0
  264. package/dist/types/shared/resolve-card-media.d.ts +1 -0
  265. package/dist/types/shared/text-split.d.ts +19 -0
  266. package/dist/types/stories/3d-flip.stories.d.ts +7 -0
  267. package/dist/types/stories/_helpers.d.ts +24 -0
  268. package/dist/types/stories/anime-splittext.stories.d.ts +8 -0
  269. package/dist/types/stories/blur-fade-in.stories.d.ts +8 -0
  270. package/dist/types/stories/blur-rise.stories.d.ts +8 -0
  271. package/dist/types/stories/blur-to-sharp-rise-header.stories.d.ts +8 -0
  272. package/dist/types/stories/border-beam.stories.d.ts +8 -0
  273. package/dist/types/stories/bounce-elastic.stories.d.ts +8 -0
  274. package/dist/types/stories/bounce-in-bottom.stories.d.ts +8 -0
  275. package/dist/types/stories/bounce-in-down.stories.d.ts +9 -0
  276. package/dist/types/stories/bubble-button.stories.d.ts +8 -0
  277. package/dist/types/stories/card-fan-spread.stories.d.ts +7 -0
  278. package/dist/types/stories/card-flip.stories.d.ts +7 -0
  279. package/dist/types/stories/confetti-button.stories.d.ts +7 -0
  280. package/dist/types/stories/float-idle.stories.d.ts +8 -0
  281. package/dist/types/stories/fly-in-chars.stories.d.ts +8 -0
  282. package/dist/types/stories/glow-cta.stories.d.ts +9 -0
  283. package/dist/types/stories/gradient-text.stories.d.ts +9 -0
  284. package/dist/types/stories/image-magnifier.stories.d.ts +10 -0
  285. package/dist/types/stories/image-zoom-rotate.stories.d.ts +7 -0
  286. package/dist/types/stories/letter-bounce.stories.d.ts +8 -0
  287. package/dist/types/stories/magic-ui-border-beam-card.stories.d.ts +8 -0
  288. package/dist/types/stories/magnetic-hover.stories.d.ts +7 -0
  289. package/dist/types/stories/pop-in-stack.stories.d.ts +7 -0
  290. package/dist/types/stories/pulse.stories.d.ts +8 -0
  291. package/dist/types/stories/rainbow-button.stories.d.ts +8 -0
  292. package/dist/types/stories/reveal-from-top.stories.d.ts +8 -0
  293. package/dist/types/stories/rgb-split-glitch.stories.d.ts +8 -0
  294. package/dist/types/stories/roll-in.stories.d.ts +9 -0
  295. package/dist/types/stories/shimmer-border.stories.d.ts +9 -0
  296. package/dist/types/stories/shimmer-text.stories.d.ts +8 -0
  297. package/dist/types/stories/shuffle.stories.d.ts +8 -0
  298. package/dist/types/stories/sketch-button.stories.d.ts +7 -0
  299. package/dist/types/stories/split-text.stories.d.ts +8 -0
  300. package/dist/types/stories/text-type.stories.d.ts +8 -0
  301. package/dist/types/stories/tilted-card.stories.d.ts +7 -0
  302. package/dist/types/stories/word-curtain-reveal.stories.d.ts +8 -0
  303. package/package.json +166 -0
  304. package/react-barrel.js +44 -0
  305. package/shared/constants.js +64 -0
  306. package/shared/meta.js +21 -0
  307. package/shared/pointer-follow.js +91 -0
  308. package/shared/reduced-motion.js +15 -0
  309. package/shared/resolve-card-media.js +41 -0
  310. package/shared/text-split.js +188 -0
@@ -0,0 +1,7 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { AnimMagneticHover } from '../animations/button/magnetic-hover/react';
3
+ import '../animations/button/magnetic-hover/style.css';
4
+ declare const meta: Meta<typeof AnimMagneticHover>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof AnimMagneticHover>;
7
+ export declare const Default: Story;
@@ -0,0 +1,7 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { AnimPopInStack } from '../animations/card/pop-in-stack/react';
3
+ import '../animations/card/pop-in-stack/style.css';
4
+ declare const meta: Meta<typeof AnimPopInStack>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof AnimPopInStack>;
7
+ export declare const Default: Story;
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { AnimPulse } from '../animations/button/pulse/react';
3
+ import '../animations/button/pulse/style.css';
4
+ declare const meta: Meta<typeof AnimPulse>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof AnimPulse>;
7
+ export declare const Default: Story;
8
+ export declare const WithContent: Story;
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { AnimRainbowButton } from '../animations/button/rainbow-button/react';
3
+ import '../animations/button/rainbow-button/style.css';
4
+ declare const meta: Meta<typeof AnimRainbowButton>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof AnimRainbowButton>;
7
+ export declare const Default: Story;
8
+ export declare const WithContent: Story;
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { AnimRevealFromTop } from '../animations/card/reveal-from-top/react';
3
+ import '../animations/card/reveal-from-top/style.css';
4
+ declare const meta: Meta<typeof AnimRevealFromTop>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof AnimRevealFromTop>;
7
+ export declare const Default: Story;
8
+ export declare const WithContent: Story;
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { AnimRgbSplitGlitch } from '../animations/card/rgb-split-glitch/react';
3
+ import '../animations/card/rgb-split-glitch/style.css';
4
+ declare const meta: Meta<typeof AnimRgbSplitGlitch>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof AnimRgbSplitGlitch>;
7
+ export declare const Default: Story;
8
+ export declare const WithContent: Story;
@@ -0,0 +1,9 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { AnimRollIn } from '../animations/header/roll-in/react';
3
+ import '../animations/header/roll-in/style.css';
4
+ declare const meta: Meta<typeof AnimRollIn>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof AnimRollIn>;
7
+ export declare const Default: Story;
8
+ export declare const WithContent: Story;
9
+ export declare const ChineseRichText: Story;
@@ -0,0 +1,9 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { AnimShimmerBorder } from '../animations/button/shimmer-border/react';
3
+ import '../animations/button/shimmer-border/style.css';
4
+ declare const meta: Meta<typeof AnimShimmerBorder>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof AnimShimmerBorder>;
7
+ export declare const Default: Story;
8
+ export declare const WithContent: Story;
9
+ export declare const Hover: Story;
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { AnimShimmerText } from '../animations/header/shimmer-text/react';
3
+ import '../animations/header/shimmer-text/style.css';
4
+ declare const meta: Meta<typeof AnimShimmerText>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof AnimShimmerText>;
7
+ export declare const Default: Story;
8
+ export declare const ChineseRichText: Story;
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { AnimShuffle } from '../animations/header/shuffle/react';
3
+ import '../animations/header/shuffle/style.css';
4
+ declare const meta: Meta<typeof AnimShuffle>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof AnimShuffle>;
7
+ export declare const Default: Story;
8
+ export declare const RichTextHeading: Story;
@@ -0,0 +1,7 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { AnimSketchButton } from '../animations/button/sketch-button/react';
3
+ import '../animations/button/sketch-button/style.css';
4
+ declare const meta: Meta<typeof AnimSketchButton>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof AnimSketchButton>;
7
+ export declare const Default: Story;
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { AnimSplitText } from '../animations/header/split-text/react';
3
+ import '../animations/header/split-text/style.css';
4
+ declare const meta: Meta<typeof AnimSplitText>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof AnimSplitText>;
7
+ export declare const Default: Story;
8
+ export declare const ChineseRichText: Story;
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { AnimTextType } from '../animations/header/text-type/react';
3
+ import '../animations/header/text-type/style.css';
4
+ declare const meta: Meta<typeof AnimTextType>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof AnimTextType>;
7
+ export declare const Default: Story;
8
+ export declare const RichTextHeading: Story;
@@ -0,0 +1,7 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { AnimTiltedCard } from '../animations/card/tilted-card/react';
3
+ import '../animations/card/tilted-card/style.css';
4
+ declare const meta: Meta<typeof AnimTiltedCard>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof AnimTiltedCard>;
7
+ export declare const Default: Story;
@@ -0,0 +1,8 @@
1
+ import type { Meta, StoryObj } from '@storybook/react';
2
+ import { AnimWordCurtainReveal } from '../animations/header/word-curtain-reveal/react';
3
+ import '../animations/header/word-curtain-reveal/style.css';
4
+ declare const meta: Meta<typeof AnimWordCurtainReveal>;
5
+ export default meta;
6
+ type Story = StoryObj<typeof AnimWordCurtainReveal>;
7
+ export declare const Default: Story;
8
+ export declare const RichTextHeading: Story;
package/package.json ADDED
@@ -0,0 +1,166 @@
1
+ {
2
+ "name": "@readdy/anim",
3
+ "version": "0.0.21",
4
+ "type": "module",
5
+ "description": "Readdy animation library — pure JS + CSS animations for the Readdy AI website editor",
6
+ "main": "dist/full.js",
7
+ "module": "dist/full.js",
8
+ "types": "dist/types/react-barrel.d.ts",
9
+ "sideEffects": [
10
+ "**/*.css"
11
+ ],
12
+ "exports": {
13
+ "./header/letter-bounce": "./animations/header/letter-bounce/index.js",
14
+ "./header/letter-bounce/style.css": "./animations/header/letter-bounce/style.css",
15
+ "./header/letter-bounce/react": "./animations/header/letter-bounce/react.tsx",
16
+ "./header/shimmer-text": "./animations/header/shimmer-text/index.js",
17
+ "./header/shimmer-text/style.css": "./animations/header/shimmer-text/style.css",
18
+ "./header/shimmer-text/react": "./animations/header/shimmer-text/react.tsx",
19
+ "./header/split-text": "./animations/header/split-text/index.js",
20
+ "./header/split-text/style.css": "./animations/header/split-text/style.css",
21
+ "./header/split-text/react": "./animations/header/split-text/react.tsx",
22
+ "./header/gradient-text": "./animations/header/gradient-text/index.js",
23
+ "./header/gradient-text/style.css": "./animations/header/gradient-text/style.css",
24
+ "./header/gradient-text/react": "./animations/header/gradient-text/react.tsx",
25
+ "./header/text-type": "./animations/header/text-type/index.js",
26
+ "./header/text-type/style.css": "./animations/header/text-type/style.css",
27
+ "./header/text-type/react": "./animations/header/text-type/react.tsx",
28
+ "./header/fly-in-chars": "./animations/header/fly-in-chars/index.js",
29
+ "./header/fly-in-chars/style.css": "./animations/header/fly-in-chars/style.css",
30
+ "./header/fly-in-chars/react": "./animations/header/fly-in-chars/react.tsx",
31
+ "./header/shuffle": "./animations/header/shuffle/index.js",
32
+ "./header/shuffle/style.css": "./animations/header/shuffle/style.css",
33
+ "./header/shuffle/react": "./animations/header/shuffle/react.tsx",
34
+ "./header/word-curtain-reveal": "./animations/header/word-curtain-reveal/index.js",
35
+ "./header/word-curtain-reveal/style.css": "./animations/header/word-curtain-reveal/style.css",
36
+ "./header/word-curtain-reveal/react": "./animations/header/word-curtain-reveal/react.tsx",
37
+ "./header/roll-in": "./animations/header/roll-in/index.js",
38
+ "./header/roll-in/style.css": "./animations/header/roll-in/style.css",
39
+ "./header/roll-in/react": "./animations/header/roll-in/react.tsx",
40
+ "./header/bounce-in-down": "./animations/header/bounce-in-down/index.js",
41
+ "./header/bounce-in-down/style.css": "./animations/header/bounce-in-down/style.css",
42
+ "./header/bounce-in-down/react": "./animations/header/bounce-in-down/react.tsx",
43
+ "./header/anime-splittext": "./animations/header/anime-splittext/index.js",
44
+ "./header/anime-splittext/style.css": "./animations/header/anime-splittext/style.css",
45
+ "./header/anime-splittext/react": "./animations/header/anime-splittext/react.tsx",
46
+ "./button/magnetic-hover": "./animations/button/magnetic-hover/index.js",
47
+ "./button/magnetic-hover/style.css": "./animations/button/magnetic-hover/style.css",
48
+ "./button/magnetic-hover/react": "./animations/button/magnetic-hover/react.tsx",
49
+ "./button/border-beam": "./animations/button/border-beam/index.js",
50
+ "./button/border-beam/style.css": "./animations/button/border-beam/style.css",
51
+ "./button/border-beam/react": "./animations/button/border-beam/react.tsx",
52
+ "./button/shimmer-border": "./animations/button/shimmer-border/index.js",
53
+ "./button/shimmer-border/style.css": "./animations/button/shimmer-border/style.css",
54
+ "./button/shimmer-border/react": "./animations/button/shimmer-border/react.tsx",
55
+ "./button/rainbow-button": "./animations/button/rainbow-button/index.js",
56
+ "./button/rainbow-button/style.css": "./animations/button/rainbow-button/style.css",
57
+ "./button/rainbow-button/react": "./animations/button/rainbow-button/react.tsx",
58
+ "./button/sketch-button": "./animations/button/sketch-button/index.js",
59
+ "./button/sketch-button/style.css": "./animations/button/sketch-button/style.css",
60
+ "./button/sketch-button/react": "./animations/button/sketch-button/react.tsx",
61
+ "./button/confetti-button": "./animations/button/confetti-button/index.js",
62
+ "./button/confetti-button/style.css": "./animations/button/confetti-button/style.css",
63
+ "./button/confetti-button/react": "./animations/button/confetti-button/react.tsx",
64
+ "./button/glow-cta": "./animations/button/glow-cta/index.js",
65
+ "./button/glow-cta/style.css": "./animations/button/glow-cta/style.css",
66
+ "./button/glow-cta/react": "./animations/button/glow-cta/react.tsx",
67
+ "./button/bubble-button": "./animations/button/bubble-button/index.js",
68
+ "./button/bubble-button/style.css": "./animations/button/bubble-button/style.css",
69
+ "./button/bubble-button/react": "./animations/button/bubble-button/react.tsx",
70
+ "./button/bounce-elastic": "./animations/button/bounce-elastic/index.js",
71
+ "./button/bounce-elastic/style.css": "./animations/button/bounce-elastic/style.css",
72
+ "./button/bounce-elastic/react": "./animations/button/bounce-elastic/react.tsx",
73
+ "./button/pulse": "./animations/button/pulse/index.js",
74
+ "./button/pulse/style.css": "./animations/button/pulse/style.css",
75
+ "./button/pulse/react": "./animations/button/pulse/react.tsx",
76
+ "./button/blur-fade-in": "./animations/button/blur-fade-in/index.js",
77
+ "./button/blur-fade-in/style.css": "./animations/button/blur-fade-in/style.css",
78
+ "./button/blur-fade-in/react": "./animations/button/blur-fade-in/react.tsx",
79
+ "./button/3d-flip": "./animations/button/3d-flip/index.js",
80
+ "./button/3d-flip/style.css": "./animations/button/3d-flip/style.css",
81
+ "./button/3d-flip/react": "./animations/button/3d-flip/react.tsx",
82
+ "./card/blur-rise": "./animations/card/blur-rise/index.js",
83
+ "./card/blur-rise/style.css": "./animations/card/blur-rise/style.css",
84
+ "./card/blur-rise/react": "./animations/card/blur-rise/react.tsx",
85
+ "./card/float-idle": "./animations/card/float-idle/index.js",
86
+ "./card/float-idle/style.css": "./animations/card/float-idle/style.css",
87
+ "./card/float-idle/react": "./animations/card/float-idle/react.tsx",
88
+ "./card/tilted-card": "./animations/card/tilted-card/index.js",
89
+ "./card/tilted-card/style.css": "./animations/card/tilted-card/style.css",
90
+ "./card/tilted-card/react": "./animations/card/tilted-card/react.tsx",
91
+ "./card/card-flip": "./animations/card/card-flip/index.js",
92
+ "./card/card-flip/style.css": "./animations/card/card-flip/style.css",
93
+ "./card/card-flip/react": "./animations/card/card-flip/react.tsx",
94
+ "./card/image-zoom-rotate": "./animations/card/image-zoom-rotate/index.js",
95
+ "./card/image-zoom-rotate/style.css": "./animations/card/image-zoom-rotate/style.css",
96
+ "./card/image-zoom-rotate/react": "./animations/card/image-zoom-rotate/react.tsx",
97
+ "./card/rgb-split-glitch": "./animations/card/rgb-split-glitch/index.js",
98
+ "./card/rgb-split-glitch/style.css": "./animations/card/rgb-split-glitch/style.css",
99
+ "./card/rgb-split-glitch/react": "./animations/card/rgb-split-glitch/react.tsx",
100
+ "./card/card-fan-spread": "./animations/card/card-fan-spread/index.js",
101
+ "./card/card-fan-spread/style.css": "./animations/card/card-fan-spread/style.css",
102
+ "./card/card-fan-spread/react": "./animations/card/card-fan-spread/react.tsx",
103
+ "./card/image-magnifier": "./animations/card/image-magnifier/index.js",
104
+ "./card/image-magnifier/style.css": "./animations/card/image-magnifier/style.css",
105
+ "./card/image-magnifier/react": "./animations/card/image-magnifier/react.tsx",
106
+ "./card/pop-in-stack": "./animations/card/pop-in-stack/index.js",
107
+ "./card/pop-in-stack/style.css": "./animations/card/pop-in-stack/style.css",
108
+ "./card/pop-in-stack/react": "./animations/card/pop-in-stack/react.tsx",
109
+ "./card/bounce-in-bottom": "./animations/card/bounce-in-bottom/index.js",
110
+ "./card/bounce-in-bottom/style.css": "./animations/card/bounce-in-bottom/style.css",
111
+ "./card/bounce-in-bottom/react": "./animations/card/bounce-in-bottom/react.tsx",
112
+ "./card/reveal-from-top": "./animations/card/reveal-from-top/index.js",
113
+ "./card/reveal-from-top/style.css": "./animations/card/reveal-from-top/style.css",
114
+ "./card/reveal-from-top/react": "./animations/card/reveal-from-top/react.tsx",
115
+ "./shared/text-split": "./shared/text-split.js",
116
+ "./react": "./react-barrel.js"
117
+ },
118
+ "files": [
119
+ "animations",
120
+ "shared",
121
+ "react-barrel.js",
122
+ "dist"
123
+ ],
124
+ "publishConfig": {
125
+ "access": "public"
126
+ },
127
+ "scripts": {
128
+ "build": "rollup -c && tsc --emitDeclarationOnly && node scripts/generate-dist-meta.js && node scripts/copy-metadata.js",
129
+ "id-map:sync": "node scripts/generate-animation-id-map.js",
130
+ "metadata:check": "node scripts/check-metadata.js",
131
+ "metadata:update": "node scripts/update-metadata.js",
132
+ "preview:sync": "node scripts/generate-preview-manifest.js && node scripts/generate-animation-id-map.js",
133
+ "preview": "npm run preview:sync && vite --config preview/vite.config.js",
134
+ "preview:build": "npm run preview:sync && vite build --config preview/vite.config.js",
135
+ "test": "vitest run",
136
+ "test:watch": "vitest",
137
+ "storybook": "storybook dev -p 6006",
138
+ "build-storybook": "storybook build",
139
+ "prepublishOnly": "npm test && npm run build"
140
+ },
141
+ "peerDependencies": {
142
+ "react": ">=17",
143
+ "react-dom": ">=17"
144
+ },
145
+ "devDependencies": {
146
+ "@rollup/plugin-node-resolve": "^16.0.3",
147
+ "@rollup/plugin-typescript": "^11.1.6",
148
+ "@storybook/addon-controls": "^9.0.8",
149
+ "@storybook/addon-docs": "^10.4.2",
150
+ "@storybook/react": "^10.4.2",
151
+ "@storybook/react-vite": "^10.4.2",
152
+ "@testing-library/react": "^16.0.0",
153
+ "@types/react": "^18.2.0",
154
+ "jsdom": "^24.0.0",
155
+ "postcss": "^8.4.38",
156
+ "react": "^18.2.0",
157
+ "react-dom": "^18.2.0",
158
+ "rollup": "^4.18.0",
159
+ "rollup-plugin-postcss": "^4.0.2",
160
+ "storybook": "^10.4.2",
161
+ "tslib": "^2.8.1",
162
+ "typescript": "^5.4.0",
163
+ "vitest": "^1.6.0"
164
+ },
165
+ "license": "MIT"
166
+ }
@@ -0,0 +1,44 @@
1
+ /**
2
+ * @readdy/anim/react — React 组件桶导出
3
+ * 用法:import { AnimBlurRise } from '@readdy/anim/react'
4
+ */
5
+
6
+ // header
7
+ export { AnimLetterBounce } from './animations/header/letter-bounce/react.tsx'
8
+ export { AnimShimmerText } from './animations/header/shimmer-text/react.tsx'
9
+ export { AnimSplitText } from './animations/header/split-text/react.tsx'
10
+ export { AnimGradientText } from './animations/header/gradient-text/react.tsx'
11
+ export { AnimTextType } from './animations/header/text-type/react.tsx'
12
+ export { AnimFlyInChars } from './animations/header/fly-in-chars/react.tsx'
13
+ export { AnimShuffle } from './animations/header/shuffle/react.tsx'
14
+ export { AnimWordCurtainReveal } from './animations/header/word-curtain-reveal/react.tsx'
15
+ export { AnimRollIn } from './animations/header/roll-in/react.tsx'
16
+ export { AnimBounceInDown } from './animations/header/bounce-in-down/react.tsx'
17
+ export { AnimAnimeSplittext } from './animations/header/anime-splittext/react.tsx'
18
+
19
+ // button
20
+ export { AnimMagneticHover } from './animations/button/magnetic-hover/react.tsx'
21
+ export { AnimBorderBeam } from './animations/button/border-beam/react.tsx'
22
+ export { AnimShimmerBorder } from './animations/button/shimmer-border/react.tsx'
23
+ export { AnimRainbowButton } from './animations/button/rainbow-button/react.tsx'
24
+ export { AnimSketchButton } from './animations/button/sketch-button/react.tsx'
25
+ export { AnimConfettiButton } from './animations/button/confetti-button/react.tsx'
26
+ export { AnimGlowCta } from './animations/button/glow-cta/react.tsx'
27
+ export { AnimBubbleButton } from './animations/button/bubble-button/react.tsx'
28
+ export { AnimBounceElastic } from './animations/button/bounce-elastic/react.tsx'
29
+ export { AnimPulse } from './animations/button/pulse/react.tsx'
30
+ export { AnimBlurFadeIn } from './animations/button/blur-fade-in/react.tsx'
31
+ export { Anim3DFlip } from './animations/button/3d-flip/react.tsx'
32
+
33
+ // card
34
+ export { AnimBlurRise } from './animations/card/blur-rise/react.tsx'
35
+ export { AnimFloatIdle } from './animations/card/float-idle/react.tsx'
36
+ export { AnimTiltedCard } from './animations/card/tilted-card/react.tsx'
37
+ export { AnimCardFlip } from './animations/card/card-flip/react.tsx'
38
+ export { AnimImageZoomRotate } from './animations/card/image-zoom-rotate/react.tsx'
39
+ export { AnimRgbSplitGlitch } from './animations/card/rgb-split-glitch/react.tsx'
40
+ export { AnimCardFanSpread } from './animations/card/card-fan-spread/react.tsx'
41
+ export { AnimImageMagnifier } from './animations/card/image-magnifier/react.tsx'
42
+ export { AnimPopInStack } from './animations/card/pop-in-stack/react.tsx'
43
+ export { AnimBounceInBottom } from './animations/card/bounce-in-bottom/react.tsx'
44
+ export { AnimRevealFromTop } from './animations/card/reveal-from-top/react.tsx'
@@ -0,0 +1,64 @@
1
+ /**
2
+ * @readdy/anim/shared/constants.js
3
+ *
4
+ * 共享常量 —— 动效 ID 前缀、class 前缀、ID 构建器
5
+ * 解决 issues #2:动效 ID 前缀不一致
6
+ */
7
+
8
+ /** 动效 ID 前缀,统一格式 */
9
+ export const ANIM_ID_PREFIX = 'readdy-anim-'
10
+
11
+ /** CSS class 前缀 */
12
+ export const ANIM_CLASS_PREFIX = 'readdy-anim-'
13
+
14
+ /**
15
+ * 构建动效 CSS class
16
+ * @param {string} name - class 后缀,如 'text-type'
17
+ * @returns {string} 完整 class,如 'readdy-anim-text-type'
18
+ */
19
+ export function buildAnimClass(name) {
20
+ return ANIM_CLASS_PREFIX + name
21
+ }
22
+
23
+ /**
24
+ * 构建动效相关 DOM id
25
+ * 目前与 class 前缀保持一致,便于 SVG filter / portal 节点等共享同一命名空间。
26
+ *
27
+ * @param {string} name - id 后缀,如 'bubble-goo'
28
+ * @returns {string} 完整 id,如 'readdy-anim-bubble-goo'
29
+ */
30
+ export function buildAnimDomId(name) {
31
+ return ANIM_CLASS_PREFIX + name
32
+ }
33
+
34
+ /**
35
+ * 构建动效规范 ID
36
+ * 统一接受动效 slug,例如:
37
+ * - buildAnimId('letter-bounce') => 'readdy-anim-letter-bounce'
38
+ * - buildAnimId('bubble-button') => 'readdy-anim-bubble-button'
39
+ *
40
+ * @param {string} name - 动效 slug
41
+ * @returns {string} 规范 ID
42
+ */
43
+ export function buildAnimId(name) {
44
+ const slug = String(name).trim()
45
+
46
+ if (!slug) {
47
+ throw new Error('buildAnimId(name) requires a non-empty animation slug')
48
+ }
49
+
50
+ if (slug.includes('/')) {
51
+ throw new Error(`buildAnimId(name) only accepts animation slugs, received path-like value: ${slug}`)
52
+ }
53
+
54
+ const normalizedSlug = slug
55
+ .replace(/[^a-zA-Z0-9]+/g, '-')
56
+ .replace(/^-+|-+$/g, '')
57
+ .toLowerCase()
58
+
59
+ if (!normalizedSlug) {
60
+ throw new Error(`buildAnimId(name) could not derive a valid animation slug from: ${slug}`)
61
+ }
62
+
63
+ return ANIM_ID_PREFIX + normalizedSlug
64
+ }
package/shared/meta.js ADDED
@@ -0,0 +1,21 @@
1
+ /**
2
+ * @readdy/anim/shared/meta.js
3
+ *
4
+ * 元数据工具 —— 从 options 定义派生默认值
5
+ * 解决 issues #3:animation.defaultOptions 字段不存在
6
+ */
7
+
8
+ /**
9
+ * 从 options 定义中提取默认值
10
+ *
11
+ * @param {Record<string, { default: any, type: string, description?: string }>} optionsDef
12
+ * 动效的 options 定义,如 { stagger: { default: 60, type: 'number' }, ... }
13
+ * @returns {Record<string, any>} 默认值对象,如 { stagger: 60, ... }
14
+ */
15
+ export function getDefaultOptions(optionsDef) {
16
+ const result = {}
17
+ for (const [key, def] of Object.entries(optionsDef)) {
18
+ result[key] = def.default
19
+ }
20
+ return result
21
+ }
@@ -0,0 +1,91 @@
1
+ export function getPointerMetrics(target, event) {
2
+ const rect =
3
+ target && typeof target.getBoundingClientRect === 'function'
4
+ ? target.getBoundingClientRect()
5
+ : target
6
+ const centerX = rect.left + rect.width / 2
7
+ const centerY = rect.top + rect.height / 2
8
+ const deltaX = event.clientX - centerX
9
+ const deltaY = event.clientY - centerY
10
+
11
+ return {
12
+ rect,
13
+ deltaX,
14
+ deltaY,
15
+ relativeX: rect.width ? deltaX / rect.width : 0,
16
+ relativeY: rect.height ? deltaY / rect.height : 0,
17
+ }
18
+ }
19
+
20
+ export function attachPointerFollow(el, handlers) {
21
+ const { onMove, onLeave, onEnter } = handlers
22
+ const requestFrame =
23
+ window.requestAnimationFrame?.bind(window) ?? ((callback) => window.setTimeout(callback, 16))
24
+ const cancelFrame =
25
+ window.cancelAnimationFrame?.bind(window) ?? ((frameId) => window.clearTimeout(frameId))
26
+
27
+ let frameId = null
28
+ let lastEvent = null
29
+ let activeRect = null
30
+
31
+ const context = {
32
+ get rect() {
33
+ return activeRect
34
+ },
35
+ refreshRect() {
36
+ activeRect = el.getBoundingClientRect()
37
+ return activeRect
38
+ },
39
+ getMetrics(event) {
40
+ return getPointerMetrics(activeRect ?? context.refreshRect(), event)
41
+ },
42
+ }
43
+
44
+ const flushMove = () => {
45
+ frameId = null
46
+ if (!lastEvent) {
47
+ return
48
+ }
49
+ if (!activeRect) {
50
+ context.refreshRect()
51
+ }
52
+ onMove(lastEvent, context)
53
+ }
54
+
55
+ const handleEnter = (event) => {
56
+ context.refreshRect()
57
+ onEnter?.(event, context)
58
+ }
59
+
60
+ const handleMove = (event) => {
61
+ lastEvent = event
62
+ if (frameId !== null) {
63
+ return
64
+ }
65
+ frameId = requestFrame(flushMove)
66
+ }
67
+
68
+ const handleLeave = (event) => {
69
+ if (frameId !== null) {
70
+ cancelFrame(frameId)
71
+ frameId = null
72
+ }
73
+ lastEvent = null
74
+ activeRect = null
75
+ onLeave?.(event, context)
76
+ }
77
+
78
+ el.addEventListener('pointerenter', handleEnter)
79
+ el.addEventListener('pointermove', handleMove)
80
+ el.addEventListener('pointerleave', handleLeave)
81
+
82
+ return () => {
83
+ if (frameId !== null) {
84
+ cancelFrame(frameId)
85
+ frameId = null
86
+ }
87
+ el.removeEventListener('pointerenter', handleEnter)
88
+ el.removeEventListener('pointermove', handleMove)
89
+ el.removeEventListener('pointerleave', handleLeave)
90
+ }
91
+ }
@@ -0,0 +1,15 @@
1
+ /**
2
+ * @readdy/anim/shared/reduced-motion.js
3
+ *
4
+ * 无障碍工具 —— 检测 prefers-reduced-motion
5
+ * 所有 React 组件和 init 函数统一使用此函数
6
+ */
7
+
8
+ /**
9
+ * 检测用户是否偏好减少动画
10
+ * @returns {boolean} true 表示用户偏好减少动画
11
+ */
12
+ export function prefersReducedMotion() {
13
+ return typeof window !== 'undefined' &&
14
+ window.matchMedia('(prefers-reduced-motion: reduce)').matches
15
+ }
@@ -0,0 +1,41 @@
1
+ function hasUsableBackgroundImage(node) {
2
+ const style = window.getComputedStyle(node)
3
+ return Boolean(style.backgroundImage && style.backgroundImage !== 'none')
4
+ }
5
+
6
+ export function resolveCardMediaElement(el, mediaClass) {
7
+ const byClass = el.querySelector(`.${mediaClass}`)
8
+ if (byClass instanceof HTMLElement) {
9
+ return byClass
10
+ }
11
+
12
+ const image = el.querySelector('img')
13
+ if (image instanceof HTMLImageElement) {
14
+ let candidate = image.parentElement
15
+ while (candidate && candidate !== el) {
16
+ const style = window.getComputedStyle(candidate)
17
+ if (
18
+ style.overflow === 'hidden' ||
19
+ style.position !== 'static' ||
20
+ candidate.childElementCount === 1 ||
21
+ hasUsableBackgroundImage(candidate)
22
+ ) {
23
+ return candidate
24
+ }
25
+ candidate = candidate.parentElement
26
+ }
27
+ }
28
+
29
+ const backgroundCandidate = Array.from(el.querySelectorAll('*')).find((node) => {
30
+ if (!(node instanceof HTMLElement)) {
31
+ return false
32
+ }
33
+ return hasUsableBackgroundImage(node)
34
+ })
35
+
36
+ if (backgroundCandidate instanceof HTMLElement) {
37
+ return backgroundCandidate
38
+ }
39
+
40
+ return el.firstElementChild instanceof HTMLElement ? el.firstElementChild : el
41
+ }