use-scroll-animate 6.0.1 → 6.1.1

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 (320) hide show
  1. package/CHANGELOG.md +31 -0
  2. package/README.md +157 -373
  3. package/README_ja.md +171 -145
  4. package/README_zh.md +169 -167
  5. package/dist/chunks/{base-B5i8qQPR.cjs → base-BaQV-2ha.cjs} +3 -3
  6. package/dist/chunks/base-BaQV-2ha.cjs.map +1 -0
  7. package/dist/chunks/{base-C3Sw9sAO.js → base-Yno7N2eC.js} +3 -3
  8. package/dist/chunks/base-Yno7N2eC.js.map +1 -0
  9. package/dist/chunks/{core-qpECfEkb.cjs → core-B5T0dhFH.cjs} +14 -210
  10. package/dist/chunks/core-B5T0dhFH.cjs.map +1 -0
  11. package/dist/chunks/{core-BDcszY4L.cjs → core-BGAyaY6L.cjs} +2 -2
  12. package/dist/chunks/{core-BDcszY4L.cjs.map → core-BGAyaY6L.cjs.map} +1 -1
  13. package/dist/chunks/{core-BTf__I-8.js → core-BIOaYdgN.js} +2 -2
  14. package/dist/chunks/{core-BTf__I-8.js.map → core-BIOaYdgN.js.map} +1 -1
  15. package/dist/chunks/{core-DN3hHbHh.js → core-CUGCsMsJ.js} +2 -2
  16. package/dist/chunks/{core-DN3hHbHh.js.map → core-CUGCsMsJ.js.map} +1 -1
  17. package/dist/chunks/{core-mV_TPgG_.js → core-D7cVumUu.js} +11 -203
  18. package/dist/chunks/core-D7cVumUu.js.map +1 -0
  19. package/dist/chunks/{core-BjOYKSrV.cjs → core-zq17EeCI.cjs} +2 -2
  20. package/dist/chunks/{core-BjOYKSrV.cjs.map → core-zq17EeCI.cjs.map} +1 -1
  21. package/dist/chunks/{fx-ChjxrMBo.js → fx-BqDeFywO.js} +2 -2
  22. package/dist/chunks/{fx-ChjxrMBo.js.map → fx-BqDeFywO.js.map} +1 -1
  23. package/dist/chunks/{fx-B8hk1Fby.cjs → fx-lBGVtQO1.cjs} +2 -2
  24. package/dist/chunks/{fx-B8hk1Fby.cjs.map → fx-lBGVtQO1.cjs.map} +1 -1
  25. package/dist/chunks/presets-BYBVJVeP.js +226 -0
  26. package/dist/chunks/presets-BYBVJVeP.js.map +1 -0
  27. package/dist/chunks/presets-CUHys3sK.cjs +233 -0
  28. package/dist/chunks/presets-CUHys3sK.cjs.map +1 -0
  29. package/dist/chunks/{spring-CckMe3x0.js → spring-DfQO5USi.js} +2 -2
  30. package/dist/chunks/{spring-CckMe3x0.js.map → spring-DfQO5USi.js.map} +1 -1
  31. package/dist/chunks/{spring--oZh55tB.cjs → spring-Dgx187Vh.cjs} +2 -2
  32. package/dist/chunks/{spring--oZh55tB.cjs.map → spring-Dgx187Vh.cjs.map} +1 -1
  33. package/dist/chunks/{stagger-CLc3j58T.cjs → stagger-CCFyhzSw.cjs} +3 -3
  34. package/dist/chunks/stagger-CCFyhzSw.cjs.map +1 -0
  35. package/dist/chunks/{stagger-BFAhKknX.js → stagger-DtMKo2SK.js} +3 -3
  36. package/dist/chunks/stagger-DtMKo2SK.js.map +1 -0
  37. package/dist/chunks/{variants-DxPmgrNX.cjs → variants-BhjyddG8.cjs} +2 -2
  38. package/dist/chunks/{variants-DxPmgrNX.cjs.map → variants-BhjyddG8.cjs.map} +1 -1
  39. package/dist/chunks/{variants-Bsevy6Xm.js → variants-VNscPeTD.js} +2 -2
  40. package/dist/chunks/{variants-Bsevy6Xm.js.map → variants-VNscPeTD.js.map} +1 -1
  41. package/dist/components/a11y.cjs +4 -4
  42. package/dist/components/a11y.cjs.map +1 -1
  43. package/dist/components/a11y.d.cts +2 -2
  44. package/dist/components/a11y.d.ts +2 -2
  45. package/dist/components/a11y.js +5 -5
  46. package/dist/components/a11y.js.map +1 -1
  47. package/dist/components/angular.cjs +8 -8
  48. package/dist/components/angular.cjs.map +1 -1
  49. package/dist/components/angular.d.cts +22 -22
  50. package/dist/components/angular.d.ts +22 -22
  51. package/dist/components/angular.js +8 -8
  52. package/dist/components/angular.js.map +1 -1
  53. package/dist/components/background.cjs +3 -3
  54. package/dist/components/background.cjs.map +1 -1
  55. package/dist/components/background.css +1 -1
  56. package/dist/components/background.d.cts +1 -1
  57. package/dist/components/background.d.ts +1 -1
  58. package/dist/components/background.js +3 -3
  59. package/dist/components/background.js.map +1 -1
  60. package/dist/components/bridge.cjs +2 -2
  61. package/dist/components/bridge.cjs.map +1 -1
  62. package/dist/components/bridge.d.cts +1 -1
  63. package/dist/components/bridge.d.ts +1 -1
  64. package/dist/components/bridge.js +2 -2
  65. package/dist/components/bridge.js.map +1 -1
  66. package/dist/components/cards.cjs +3 -3
  67. package/dist/components/cards.cjs.map +1 -1
  68. package/dist/components/cards.css +1 -1
  69. package/dist/components/cards.d.cts +1 -1
  70. package/dist/components/cards.d.ts +1 -1
  71. package/dist/components/cards.js +3 -3
  72. package/dist/components/cards.js.map +1 -1
  73. package/dist/components/click.cjs +4 -4
  74. package/dist/components/click.cjs.map +1 -1
  75. package/dist/components/click.css +1 -1
  76. package/dist/components/click.d.cts +1 -1
  77. package/dist/components/click.d.ts +1 -1
  78. package/dist/components/click.js +4 -4
  79. package/dist/components/click.js.map +1 -1
  80. package/dist/components/depth.cjs +4 -4
  81. package/dist/components/depth.cjs.map +1 -1
  82. package/dist/components/depth.css +1 -1
  83. package/dist/components/depth.d.cts +1 -1
  84. package/dist/components/depth.d.ts +1 -1
  85. package/dist/components/depth.js +4 -4
  86. package/dist/components/depth.js.map +1 -1
  87. package/dist/components/effects.cjs +13 -13
  88. package/dist/components/effects.cjs.map +1 -1
  89. package/dist/components/effects.d.cts +2 -2
  90. package/dist/components/effects.d.ts +2 -2
  91. package/dist/components/effects.js +13 -13
  92. package/dist/components/effects.js.map +1 -1
  93. package/dist/components/feedback.cjs +2 -2
  94. package/dist/components/feedback.cjs.map +1 -1
  95. package/dist/components/feedback.css +1 -1
  96. package/dist/components/feedback.d.cts +1 -1
  97. package/dist/components/feedback.d.ts +1 -1
  98. package/dist/components/feedback.js +2 -2
  99. package/dist/components/feedback.js.map +1 -1
  100. package/dist/components/fx.cjs +10 -10
  101. package/dist/components/fx.cjs.map +1 -1
  102. package/dist/components/fx.css +1 -1
  103. package/dist/components/fx.d.cts +2 -2
  104. package/dist/components/fx.d.ts +2 -2
  105. package/dist/components/fx.js +10 -10
  106. package/dist/components/fx.js.map +1 -1
  107. package/dist/components/gesture.cjs +4 -4
  108. package/dist/components/gesture.cjs.map +1 -1
  109. package/dist/components/gesture.css +1 -1
  110. package/dist/components/gesture.d.cts +1 -1
  111. package/dist/components/gesture.d.ts +1 -1
  112. package/dist/components/gesture.js +5 -5
  113. package/dist/components/gesture.js.map +1 -1
  114. package/dist/components/interaction.cjs +2 -2
  115. package/dist/components/interaction.cjs.map +1 -1
  116. package/dist/components/interaction.css +1 -1
  117. package/dist/components/interaction.d.cts +1 -1
  118. package/dist/components/interaction.d.ts +1 -1
  119. package/dist/components/interaction.js +2 -2
  120. package/dist/components/interaction.js.map +1 -1
  121. package/dist/components/jsx.d.cts +2 -2
  122. package/dist/components/jsx.d.ts +2 -2
  123. package/dist/components/layout.cjs +2 -2
  124. package/dist/components/layout.cjs.map +1 -1
  125. package/dist/components/layout.css +1 -1
  126. package/dist/components/layout.d.cts +1 -1
  127. package/dist/components/layout.d.ts +1 -1
  128. package/dist/components/layout.js +2 -2
  129. package/dist/components/layout.js.map +1 -1
  130. package/dist/components/lazy.cjs +2 -2
  131. package/dist/components/lazy.cjs.map +1 -1
  132. package/dist/components/lazy.d.cts +2 -2
  133. package/dist/components/lazy.d.ts +2 -2
  134. package/dist/components/lazy.js +2 -2
  135. package/dist/components/lazy.js.map +1 -1
  136. package/dist/components/lite.cjs +45 -41
  137. package/dist/components/lite.cjs.map +1 -1
  138. package/dist/components/lite.js +45 -41
  139. package/dist/components/lite.js.map +1 -1
  140. package/dist/components/packs.cjs +2 -2
  141. package/dist/components/packs.cjs.map +1 -1
  142. package/dist/components/packs.css +1 -1
  143. package/dist/components/packs.d.cts +1 -1
  144. package/dist/components/packs.d.ts +1 -1
  145. package/dist/components/packs.js +2 -2
  146. package/dist/components/packs.js.map +1 -1
  147. package/dist/components/page.cjs +3 -3
  148. package/dist/components/page.cjs.map +1 -1
  149. package/dist/components/page.css +1 -1
  150. package/dist/components/page.d.cts +1 -1
  151. package/dist/components/page.d.ts +1 -1
  152. package/dist/components/page.js +4 -4
  153. package/dist/components/page.js.map +1 -1
  154. package/dist/components/perf.cjs +3 -3
  155. package/dist/components/perf.cjs.map +1 -1
  156. package/dist/components/perf.d.cts +2 -2
  157. package/dist/components/perf.d.ts +2 -2
  158. package/dist/components/perf.js +4 -4
  159. package/dist/components/perf.js.map +1 -1
  160. package/dist/components/physics.cjs +3 -3
  161. package/dist/components/physics.cjs.map +1 -1
  162. package/dist/components/physics.css +1 -1
  163. package/dist/components/physics.d.cts +1 -1
  164. package/dist/components/physics.d.ts +1 -1
  165. package/dist/components/physics.js +4 -4
  166. package/dist/components/physics.js.map +1 -1
  167. package/dist/components/react.cjs +4 -4
  168. package/dist/components/react.cjs.map +1 -1
  169. package/dist/components/react.js +4 -4
  170. package/dist/components/react.js.map +1 -1
  171. package/dist/components/reveal.cjs +6 -2
  172. package/dist/components/reveal.cjs.map +1 -1
  173. package/dist/components/reveal.css +1 -1
  174. package/dist/components/reveal.d.cts +1 -1
  175. package/dist/components/reveal.d.ts +1 -1
  176. package/dist/components/reveal.js +6 -2
  177. package/dist/components/reveal.js.map +1 -1
  178. package/dist/components/solid.cjs +9 -9
  179. package/dist/components/solid.cjs.map +1 -1
  180. package/dist/components/solid.d.cts +22 -22
  181. package/dist/components/solid.d.ts +22 -22
  182. package/dist/components/solid.js +9 -9
  183. package/dist/components/solid.js.map +1 -1
  184. package/dist/components/svelte.cjs +8 -8
  185. package/dist/components/svelte.cjs.map +1 -1
  186. package/dist/components/svelte.d.cts +22 -22
  187. package/dist/components/svelte.d.ts +22 -22
  188. package/dist/components/svelte.js +8 -8
  189. package/dist/components/svelte.js.map +1 -1
  190. package/dist/components/svg.cjs +2 -2
  191. package/dist/components/svg.cjs.map +1 -1
  192. package/dist/components/svg.css +1 -1
  193. package/dist/components/svg.d.cts +1 -1
  194. package/dist/components/svg.d.ts +1 -1
  195. package/dist/components/svg.js +2 -2
  196. package/dist/components/svg.js.map +1 -1
  197. package/dist/components/text.cjs +3 -3
  198. package/dist/components/text.cjs.map +1 -1
  199. package/dist/components/text.css +1 -1
  200. package/dist/components/text.d.cts +1 -1
  201. package/dist/components/text.d.ts +1 -1
  202. package/dist/components/text.js +3 -3
  203. package/dist/components/text.js.map +1 -1
  204. package/dist/components/timeline.cjs +3 -3
  205. package/dist/components/timeline.cjs.map +1 -1
  206. package/dist/components/timeline.css +1 -1
  207. package/dist/components/timeline.d.cts +1 -1
  208. package/dist/components/timeline.d.ts +1 -1
  209. package/dist/components/timeline.js +4 -4
  210. package/dist/components/timeline.js.map +1 -1
  211. package/dist/components/tokens.cjs +2 -2
  212. package/dist/components/tokens.cjs.map +1 -1
  213. package/dist/components/tokens.d.cts +2 -2
  214. package/dist/components/tokens.d.ts +2 -2
  215. package/dist/components/tokens.js +2 -2
  216. package/dist/components/tokens.js.map +1 -1
  217. package/dist/components/transitions.cjs +2 -2
  218. package/dist/components/transitions.cjs.map +1 -1
  219. package/dist/components/transitions.css +1 -1
  220. package/dist/components/transitions.d.cts +1 -1
  221. package/dist/components/transitions.d.ts +1 -1
  222. package/dist/components/transitions.js +2 -2
  223. package/dist/components/transitions.js.map +1 -1
  224. package/dist/components/ui.cjs +4 -4
  225. package/dist/components/ui.cjs.map +1 -1
  226. package/dist/components/ui.css +1 -1
  227. package/dist/components/ui.d.cts +1 -1
  228. package/dist/components/ui.d.ts +1 -1
  229. package/dist/components/ui.js +5 -5
  230. package/dist/components/ui.js.map +1 -1
  231. package/dist/components/vue.cjs +9 -9
  232. package/dist/components/vue.cjs.map +1 -1
  233. package/dist/components/vue.d.cts +23 -23
  234. package/dist/components/vue.d.ts +23 -23
  235. package/dist/components/vue.js +9 -9
  236. package/dist/components/vue.js.map +1 -1
  237. package/dist/components/webgl.cjs +2 -2
  238. package/dist/components/webgl.cjs.map +1 -1
  239. package/dist/components/webgl.css +1 -1
  240. package/dist/components/webgl.d.cts +1 -1
  241. package/dist/components/webgl.d.ts +1 -1
  242. package/dist/components/webgl.js +2 -2
  243. package/dist/components/webgl.js.map +1 -1
  244. package/dist/components.cjs +9 -9
  245. package/dist/components.cjs.map +1 -1
  246. package/dist/components.css +1 -1
  247. package/dist/components.d.cts +30 -30
  248. package/dist/components.d.ts +30 -30
  249. package/dist/components.js +11 -11
  250. package/dist/components.js.map +1 -1
  251. package/dist/components.umd.js +5 -5
  252. package/dist/components.umd.js.map +1 -1
  253. package/dist/element.cjs +4 -3
  254. package/dist/element.cjs.map +1 -1
  255. package/dist/element.d.cts +19 -5
  256. package/dist/element.d.ts +19 -5
  257. package/dist/element.js +4 -3
  258. package/dist/element.js.map +1 -1
  259. package/dist/element.umd.js +1 -1
  260. package/dist/element.umd.js.map +1 -1
  261. package/dist/index.cjs +28 -25
  262. package/dist/index.cjs.map +1 -1
  263. package/dist/index.d.cts +40 -15
  264. package/dist/index.d.ts +40 -15
  265. package/dist/index.js +11 -10
  266. package/dist/index.js.map +1 -1
  267. package/dist/index.umd.js +5 -5
  268. package/dist/index.umd.js.map +1 -1
  269. package/dist/presets/extended.cjs +243 -0
  270. package/dist/presets/extended.cjs.map +1 -0
  271. package/dist/presets/extended.d.cts +37 -0
  272. package/dist/presets/extended.d.ts +37 -0
  273. package/dist/presets/extended.js +239 -0
  274. package/dist/presets/extended.js.map +1 -0
  275. package/dist/presets-extended.umd.js +2 -0
  276. package/dist/presets-extended.umd.js.map +1 -0
  277. package/dist/react.cjs +4 -3
  278. package/dist/react.cjs.map +1 -1
  279. package/dist/react.d.cts +19 -5
  280. package/dist/react.d.ts +19 -5
  281. package/dist/react.js +4 -3
  282. package/dist/react.js.map +1 -1
  283. package/dist/solid.cjs +5 -4
  284. package/dist/solid.cjs.map +1 -1
  285. package/dist/solid.d.cts +20 -6
  286. package/dist/solid.d.ts +20 -6
  287. package/dist/solid.js +5 -4
  288. package/dist/solid.js.map +1 -1
  289. package/dist/svelte.cjs +5 -4
  290. package/dist/svelte.cjs.map +1 -1
  291. package/dist/svelte.d.cts +20 -6
  292. package/dist/svelte.d.ts +20 -6
  293. package/dist/svelte.js +5 -4
  294. package/dist/svelte.js.map +1 -1
  295. package/dist/vue.cjs +4 -3
  296. package/dist/vue.cjs.map +1 -1
  297. package/dist/vue.d.cts +19 -5
  298. package/dist/vue.d.ts +19 -5
  299. package/dist/vue.js +4 -3
  300. package/dist/vue.js.map +1 -1
  301. package/docs/API.md +17 -12
  302. package/docs/ROADMAP.md +12 -11
  303. package/docs/accessibility.md +2 -2
  304. package/docs/components.md +33 -33
  305. package/docs/frameworks-ssr.md +12 -12
  306. package/docs/hybrid-apps.md +10 -10
  307. package/docs/migration-from-aos.md +5 -5
  308. package/docs/migration-from-gsap-scrolltrigger.md +3 -3
  309. package/docs/motion-tokens.css +1 -1
  310. package/docs/motion-tokens.md +2 -2
  311. package/docs/performance.md +6 -6
  312. package/docs/presets.md +310 -0
  313. package/docs/windows-apps.md +8 -8
  314. package/package.json +40 -26
  315. package/dist/chunks/base-B5i8qQPR.cjs.map +0 -1
  316. package/dist/chunks/base-C3Sw9sAO.js.map +0 -1
  317. package/dist/chunks/core-mV_TPgG_.js.map +0 -1
  318. package/dist/chunks/core-qpECfEkb.cjs.map +0 -1
  319. package/dist/chunks/stagger-BFAhKknX.js.map +0 -1
  320. package/dist/chunks/stagger-CLc3j58T.cjs.map +0 -1
package/dist/solid.js CHANGED
@@ -1,12 +1,13 @@
1
1
  import { createRenderEffect, onMount, onCleanup } from 'solid-js';
2
- import { c as createScrollAnimate } from './chunks/core-mV_TPgG_.js';
3
- import { s as staggerChildren } from './chunks/stagger-BFAhKknX.js';
2
+ import { c as createScrollAnimate } from './chunks/core-D7cVumUu.js';
3
+ import { s as staggerChildren } from './chunks/stagger-DtMKo2SK.js';
4
+ import './chunks/presets-BYBVJVeP.js';
4
5
 
5
6
  /**
6
- * use-scroll-animate - Solid integration
7
+ * motionary - Solid integration
7
8
  *
8
9
  * ```tsx
9
- * import { scrollAnimate, scrollStagger, useScrollAnimate } from 'use-scroll-animate/solid';
10
+ * import { scrollAnimate, scrollStagger, useScrollAnimate } from 'motionary/solid';
10
11
  * false && scrollAnimate; // keep the directive import (TypeScript)
11
12
  *
12
13
  * <div use:scrollAnimate={{ animation: 'zoom-in' }}>…</div>
package/dist/solid.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"solid.js","sources":["../src/solid.ts"],"sourcesContent":["/**\n * use-scroll-animate - Solid integration\n *\n * ```tsx\n * import { scrollAnimate, scrollStagger, useScrollAnimate } from 'use-scroll-animate/solid';\n * false && scrollAnimate; // keep the directive import (TypeScript)\n *\n * <div use:scrollAnimate={{ animation: 'zoom-in' }}>…</div>\n * <ul use:scrollStagger={{ stagger: 60 }}>…</ul>\n * <div ref={useScrollAnimate({ animation: 'fade-in-up' })}>…</div>\n * ```\n *\n * `solid-js` is an optional peer dependency (only needed for this entry).\n */\n\nimport { createRenderEffect, onCleanup, onMount } from 'solid-js';\nimport type { AnimateOptions, ScrollAnimateInstance } from './types';\nimport { createScrollAnimate } from './core';\nimport { staggerChildren, type StaggerOptions } from './stagger';\n\nexport interface SolidScrollAnimateOptions extends AnimateOptions {\n instance?: ScrollAnimateInstance;\n}\nexport interface SolidScrollStaggerOptions extends StaggerOptions {\n instance?: ScrollAnimateInstance;\n}\n\ndeclare module 'solid-js' {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface Directives {\n scrollAnimate: SolidScrollAnimateOptions | true;\n scrollStagger: SolidScrollStaggerOptions | true;\n }\n }\n}\n\nlet shared: ScrollAnimateInstance | null = null;\nconst getInstance = (own?: ScrollAnimateInstance) => own || shared || (shared = createScrollAnimate());\n\nfunction read<T>(accessor?: () => T | true | undefined): T {\n const v = accessor?.();\n return (v && v !== true ? v : {}) as T;\n}\n\nconst CALLBACKS = ['onStart', 'onComplete', 'onEnter', 'onLeave', 'onProgress'] as const;\n\n/** Callbacks always call the latest options' version. */\nfunction liveCallbacks(opts: AnimateOptions, latest: () => AnimateOptions): AnimateOptions {\n const out: AnimateOptions = { ...opts };\n CALLBACKS.forEach((name) => {\n if (typeof opts[name] === 'function') (out as any)[name] = (...args: unknown[]) => (latest()[name] as any)?.(...args);\n });\n return out;\n}\n\n/**\n * Directive: `<div use:scrollAnimate={{ animation: 'fade-in' }} />`.\n * 4.0.1: the accessor is tracked — when signals it reads change, callbacks\n * update right away and the other options are re-applied if the element has\n * not animated yet (no manual `refresh()` needed).\n */\nexport function scrollAnimate(el: Element, accessor?: () => SolidScrollAnimateOptions | true | undefined): void {\n let latest: SolidScrollAnimateOptions = {};\n let mounted = false;\n let sa: ScrollAnimateInstance | null = null;\n const apply = () => {\n const { instance, ...opts } = latest;\n const record = sa?.getObservedElements().find((r) => r.element === el);\n if (sa && record?.animated) return; // finished: callbacks stay live\n sa?.unobserve(el);\n sa = getInstance(instance);\n sa.observe(el, liveCallbacks(opts, () => latest));\n };\n createRenderEffect(() => {\n latest = read<SolidScrollAnimateOptions>(accessor);\n if (mounted) apply();\n });\n // Wait until the element is in the document (directives/refs run before insertion).\n onMount(() => {\n mounted = true;\n apply();\n });\n onCleanup(() => sa?.unobserve(el));\n}\n\n/** Directive: `<ul use:scrollStagger={{ stagger: 60, observeChildren: true }} />` */\nexport function scrollStagger(el: Element, accessor?: () => SolidScrollStaggerOptions | true | undefined): void {\n const { instance, ...opts } = read<SolidScrollStaggerOptions>(accessor);\n let stop: (() => void) | undefined;\n onMount(() => {\n stop = staggerChildren(el, opts, getInstance(instance));\n });\n onCleanup(() => stop?.());\n}\n\n/** Primitive returning a `ref` callback: `<div ref={useScrollAnimate({ animation: 'fade-in-up' })} />` */\nexport function useScrollAnimate(options: SolidScrollAnimateOptions = {}): (el: Element) => void {\n let el: Element | undefined;\n const { instance, ...opts } = options;\n const sa = getInstance(instance);\n onMount(() => el && sa.observe(el, opts));\n onCleanup(() => el && sa.unobserve(el));\n return (node: Element) => {\n el = node;\n };\n}\n"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;;AAaG;AAwBH,IAAI,MAAM,GAAiC,IAAI;AAC/C,MAAM,WAAW,GAAG,CAAC,GAA2B,KAAK,GAAG,IAAI,MAAM,KAAK,MAAM,GAAG,mBAAmB,EAAE,CAAC;AAEtG,SAAS,IAAI,CAAI,QAAqC,EAAA;AACpD,IAAA,MAAM,CAAC,GAAG,QAAQ,IAAI;AACtB,IAAA,QAAQ,CAAC,IAAI,CAAC,KAAK,IAAI,GAAG,CAAC,GAAG,EAAE;AAClC;AAEA,MAAM,SAAS,GAAG,CAAC,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAU;AAExF;AACA,SAAS,aAAa,CAAC,IAAoB,EAAE,MAA4B,EAAA;AACvE,IAAA,MAAM,GAAG,GAAmB,EAAE,GAAG,IAAI,EAAE;AACvC,IAAA,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;AACzB,QAAA,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,UAAU;YAAG,GAAW,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAe,KAAM,MAAM,EAAE,CAAC,IAAI,CAAS,GAAG,GAAG,IAAI,CAAC;AACvH,IAAA,CAAC,CAAC;AACF,IAAA,OAAO,GAAG;AACZ;AAEA;;;;;AAKG;AACG,SAAU,aAAa,CAAC,EAAW,EAAE,QAA6D,EAAA;IACtG,IAAI,MAAM,GAA8B,EAAE;IAC1C,IAAI,OAAO,GAAG,KAAK;IACnB,IAAI,EAAE,GAAiC,IAAI;IAC3C,MAAM,KAAK,GAAG,MAAK;QACjB,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,MAAM;QACpC,MAAM,MAAM,GAAG,EAAE,EAAE,mBAAmB,EAAE,CAAC,IAAI,CAA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,IAAI,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,IAAI,CAAC,CAAC;AACzC,IAAA,SAAS,CAAC,MAAM,EAAE,IAAI,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC;IACvC,OAAO,CAAC,IAAa,KAAI;QACvB,EAAE,GAAG,IAAI;AACX,IAAA,CAAC;AACH;;;;"}
1
+ {"version":3,"file":"solid.js","sources":["../src/solid.ts"],"sourcesContent":["/**\n * motionary - Solid integration\n *\n * ```tsx\n * import { scrollAnimate, scrollStagger, useScrollAnimate } from 'motionary/solid';\n * false && scrollAnimate; // keep the directive import (TypeScript)\n *\n * <div use:scrollAnimate={{ animation: 'zoom-in' }}>…</div>\n * <ul use:scrollStagger={{ stagger: 60 }}>…</ul>\n * <div ref={useScrollAnimate({ animation: 'fade-in-up' })}>…</div>\n * ```\n *\n * `solid-js` is an optional peer dependency (only needed for this entry).\n */\n\nimport { createRenderEffect, onCleanup, onMount } from 'solid-js';\nimport type { AnimateOptions, ScrollAnimateInstance } from './types';\nimport { createScrollAnimate } from './core';\nimport { staggerChildren, type StaggerOptions } from './stagger';\n\nexport interface SolidScrollAnimateOptions extends AnimateOptions {\n instance?: ScrollAnimateInstance;\n}\nexport interface SolidScrollStaggerOptions extends StaggerOptions {\n instance?: ScrollAnimateInstance;\n}\n\ndeclare module 'solid-js' {\n // eslint-disable-next-line @typescript-eslint/no-namespace\n namespace JSX {\n interface Directives {\n scrollAnimate: SolidScrollAnimateOptions | true;\n scrollStagger: SolidScrollStaggerOptions | true;\n }\n }\n}\n\nlet shared: ScrollAnimateInstance | null = null;\nconst getInstance = (own?: ScrollAnimateInstance) => own || shared || (shared = createScrollAnimate());\n\nfunction read<T>(accessor?: () => T | true | undefined): T {\n const v = accessor?.();\n return (v && v !== true ? v : {}) as T;\n}\n\nconst CALLBACKS = ['onStart', 'onComplete', 'onEnter', 'onLeave', 'onProgress'] as const;\n\n/** Callbacks always call the latest options' version. */\nfunction liveCallbacks(opts: AnimateOptions, latest: () => AnimateOptions): AnimateOptions {\n const out: AnimateOptions = { ...opts };\n CALLBACKS.forEach((name) => {\n if (typeof opts[name] === 'function') (out as any)[name] = (...args: unknown[]) => (latest()[name] as any)?.(...args);\n });\n return out;\n}\n\n/**\n * Directive: `<div use:scrollAnimate={{ animation: 'fade-in' }} />`.\n * 4.0.1: the accessor is tracked — when signals it reads change, callbacks\n * update right away and the other options are re-applied if the element has\n * not animated yet (no manual `refresh()` needed).\n */\nexport function scrollAnimate(el: Element, accessor?: () => SolidScrollAnimateOptions | true | undefined): void {\n let latest: SolidScrollAnimateOptions = {};\n let mounted = false;\n let sa: ScrollAnimateInstance | null = null;\n const apply = () => {\n const { instance, ...opts } = latest;\n const record = sa?.getObservedElements().find((r) => r.element === el);\n if (sa && record?.animated) return; // finished: callbacks stay live\n sa?.unobserve(el);\n sa = getInstance(instance);\n sa.observe(el, liveCallbacks(opts, () => latest));\n };\n createRenderEffect(() => {\n latest = read<SolidScrollAnimateOptions>(accessor);\n if (mounted) apply();\n });\n // Wait until the element is in the document (directives/refs run before insertion).\n onMount(() => {\n mounted = true;\n apply();\n });\n onCleanup(() => sa?.unobserve(el));\n}\n\n/** Directive: `<ul use:scrollStagger={{ stagger: 60, observeChildren: true }} />` */\nexport function scrollStagger(el: Element, accessor?: () => SolidScrollStaggerOptions | true | undefined): void {\n const { instance, ...opts } = read<SolidScrollStaggerOptions>(accessor);\n let stop: (() => void) | undefined;\n onMount(() => {\n stop = staggerChildren(el, opts, getInstance(instance));\n });\n onCleanup(() => stop?.());\n}\n\n/** Primitive returning a `ref` callback: `<div ref={useScrollAnimate({ animation: 'fade-in-up' })} />` */\nexport function useScrollAnimate(options: SolidScrollAnimateOptions = {}): (el: Element) => void {\n let el: Element | undefined;\n const { instance, ...opts } = options;\n const sa = getInstance(instance);\n onMount(() => el && sa.observe(el, opts));\n onCleanup(() => el && sa.unobserve(el));\n return (node: Element) => {\n el = node;\n };\n}\n"],"names":[],"mappings":";;;;;AAAA;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AAS,CAAC,EAAE,CAAC,CAAC;IACvC,OAAO,CAAC,IAAa,KAAI;QACvB,EAAE,GAAG,IAAI;AACX,IAAA,CAAC;AACH;;;;"}
package/dist/svelte.cjs CHANGED
@@ -1,16 +1,17 @@
1
1
  'use strict';
2
2
 
3
- var core = require('./chunks/core-qpECfEkb.cjs');
4
- var stagger = require('./chunks/stagger-CLc3j58T.cjs');
3
+ var core = require('./chunks/core-B5T0dhFH.cjs');
4
+ var stagger = require('./chunks/stagger-CCFyhzSw.cjs');
5
+ require('./chunks/presets-CUHys3sK.cjs');
5
6
 
6
7
  /**
7
- * use-scroll-animate - Svelte integration
8
+ * motionary - Svelte integration
8
9
  *
9
10
  * Svelte actions (no import from `svelte` needed, works with Svelte 3, 4 and 5):
10
11
  *
11
12
  * ```svelte
12
13
  * <script>
13
- * import { scrollAnimate, scrollStagger } from 'use-scroll-animate/svelte';
14
+ * import { scrollAnimate, scrollStagger } from 'motionary/svelte';
14
15
  * </script>
15
16
  * <div use:scrollAnimate={{ animation: 'fade-in-up', duration: 800 }}>…</div>
16
17
  * <ul use:scrollStagger={{ stagger: 60 }}>…</ul>
@@ -1 +1 @@
1
- {"version":3,"file":"svelte.cjs","sources":["../src/svelte.ts"],"sourcesContent":["/**\n * use-scroll-animate - Svelte integration\n *\n * Svelte actions (no import from `svelte` needed, works with Svelte 3, 4 and 5):\n *\n * ```svelte\n * <script>\n * import { scrollAnimate, scrollStagger } from 'use-scroll-animate/svelte';\n * </script>\n * <div use:scrollAnimate={{ animation: 'fade-in-up', duration: 800 }}>…</div>\n * <ul use:scrollStagger={{ stagger: 60 }}>…</ul>\n * ```\n */\n\nimport type { AnimateOptions, ScrollAnimateInstance } from './types';\nimport { createScrollAnimate } from './core';\nimport { staggerChildren, type StaggerOptions } from './stagger';\n\nexport interface ScrollAnimateActionOptions extends AnimateOptions {\n /** Instance to register with (default: a shared instance created on first use) */\n instance?: ScrollAnimateInstance;\n}\n\nexport interface ScrollStaggerActionOptions extends StaggerOptions {\n instance?: ScrollAnimateInstance;\n}\n\n/** Shape of a Svelte action's return value. */\nexport interface ActionReturn<P> {\n update?: (parameter: P) => void;\n destroy?: () => void;\n}\n\nlet shared: ScrollAnimateInstance | null = null;\nconst getInstance = (own?: ScrollAnimateInstance) => own || shared || (shared = createScrollAnimate());\n\nconst CALLBACKS = ['onStart', 'onComplete', 'onEnter', 'onLeave', 'onProgress'] as const;\n\n/** Callbacks always call the latest parameter's version. */\nfunction liveCallbacks(opts: AnimateOptions, latest: () => AnimateOptions): AnimateOptions {\n const out: AnimateOptions = { ...opts };\n CALLBACKS.forEach((name) => {\n if (typeof opts[name] === 'function') (out as any)[name] = (...args: unknown[]) => (latest()[name] as any)?.(...args);\n });\n return out;\n}\n\n/**\n * Animate `node` when it scrolls into view. Changing the parameter updates the\n * callbacks right away; other options are applied if the element has not\n * animated yet.\n */\nexport function scrollAnimate(\n node: Element,\n options: ScrollAnimateActionOptions = {}\n): ActionReturn<ScrollAnimateActionOptions | undefined> {\n let current = options;\n const { instance, ...opts } = options;\n const sa = getInstance(instance);\n sa.observe(node, liveCallbacks(opts, () => current));\n\n return {\n update(next = {}) {\n current = next;\n const record = sa.getObservedElements().find((r) => r.element === node);\n if (record && !record.animated) {\n const { instance: _ignored, ...nextOpts } = next;\n sa.unobserve(node);\n sa.observe(node, liveCallbacks(nextOpts, () => current));\n }\n },\n destroy() {\n sa.unobserve(node);\n },\n };\n}\n\n/** Stagger the children of `node` when it scrolls into view (`observeChildren: true` also animates children added later). */\nexport function scrollStagger(\n node: Element,\n options: ScrollStaggerActionOptions = {}\n): ActionReturn<ScrollStaggerActionOptions | undefined> {\n const { instance, ...opts } = options;\n const stop = staggerChildren(node, opts, getInstance(instance));\n return { destroy: stop };\n}\n"],"names":["createScrollAnimate","staggerChildren"],"mappings":";;;;;AAAA;;;;;;;;;;;;AAYG;AAqBH,IAAI,MAAM,GAAiC,IAAI;AAC/C,MAAM,WAAW,GAAG,CAAC,GAA2B,KAAK,GAAG,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ClB,gBAAA,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,aAAa,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC;YAC1D;QACF,CAAC;QACD,OAAO,GAAA;AACL,YAAA,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC;QACpB,CAAC;KACF;AACH;AAEA;SACgB,aAAa,CAC3B,IAAa,EACb,UAAsC,EAAE,EAAA;IAExC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO;AACrC,IAAA,MAAM,IAAI,GAAGC,uBAAe,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;AAC/D,IAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AAC1B;;;;;"}
1
+ {"version":3,"file":"svelte.cjs","sources":["../src/svelte.ts"],"sourcesContent":["/**\n * motionary - Svelte integration\n *\n * Svelte actions (no import from `svelte` needed, works with Svelte 3, 4 and 5):\n *\n * ```svelte\n * <script>\n * import { scrollAnimate, scrollStagger } from 'motionary/svelte';\n * </script>\n * <div use:scrollAnimate={{ animation: 'fade-in-up', duration: 800 }}>…</div>\n * <ul use:scrollStagger={{ stagger: 60 }}>…</ul>\n * ```\n */\n\nimport type { AnimateOptions, ScrollAnimateInstance } from './types';\nimport { createScrollAnimate } from './core';\nimport { staggerChildren, type StaggerOptions } from './stagger';\n\nexport interface ScrollAnimateActionOptions extends AnimateOptions {\n /** Instance to register with (default: a shared instance created on first use) */\n instance?: ScrollAnimateInstance;\n}\n\nexport interface ScrollStaggerActionOptions extends StaggerOptions {\n instance?: ScrollAnimateInstance;\n}\n\n/** Shape of a Svelte action's return value. */\nexport interface ActionReturn<P> {\n update?: (parameter: P) => void;\n destroy?: () => void;\n}\n\nlet shared: ScrollAnimateInstance | null = null;\nconst getInstance = (own?: ScrollAnimateInstance) => own || shared || (shared = createScrollAnimate());\n\nconst CALLBACKS = ['onStart', 'onComplete', 'onEnter', 'onLeave', 'onProgress'] as const;\n\n/** Callbacks always call the latest parameter's version. */\nfunction liveCallbacks(opts: AnimateOptions, latest: () => AnimateOptions): AnimateOptions {\n const out: AnimateOptions = { ...opts };\n CALLBACKS.forEach((name) => {\n if (typeof opts[name] === 'function') (out as any)[name] = (...args: unknown[]) => (latest()[name] as any)?.(...args);\n });\n return out;\n}\n\n/**\n * Animate `node` when it scrolls into view. Changing the parameter updates the\n * callbacks right away; other options are applied if the element has not\n * animated yet.\n */\nexport function scrollAnimate(\n node: Element,\n options: ScrollAnimateActionOptions = {}\n): ActionReturn<ScrollAnimateActionOptions | undefined> {\n let current = options;\n const { instance, ...opts } = options;\n const sa = getInstance(instance);\n sa.observe(node, liveCallbacks(opts, () => current));\n\n return {\n update(next = {}) {\n current = next;\n const record = sa.getObservedElements().find((r) => r.element === node);\n if (record && !record.animated) {\n const { instance: _ignored, ...nextOpts } = next;\n sa.unobserve(node);\n sa.observe(node, liveCallbacks(nextOpts, () => current));\n }\n },\n destroy() {\n sa.unobserve(node);\n },\n };\n}\n\n/** Stagger the children of `node` when it scrolls into view (`observeChildren: true` also animates children added later). */\nexport function scrollStagger(\n node: Element,\n options: ScrollStaggerActionOptions = {}\n): ActionReturn<ScrollStaggerActionOptions | undefined> {\n const { instance, ...opts } = options;\n const stop = staggerChildren(node, opts, getInstance(instance));\n return { destroy: stop };\n}\n"],"names":["createScrollAnimate","staggerChildren"],"mappings":";;;;;;AAAA;;;;;;;;;;;;AAYG;AAqBH,IAAI,MAAM,GAAiC,IAAI;AAC/C,MAAM,WAAW,GAAG,CAAC,GAA2B,KAAK,GAAG,IAAI,MAAM,KAAK,MAAM,GAAGA,wBAAmB,EAAE,CAAC;AAEtG,MAAM,SAAS,GAAG,CAAC,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAU;AAExF;AACA,SAAS,aAAa,CAAC,IAAoB,EAAE,MAA4B,EAAA;AACvE,IAAA,MAAM,GAAG,GAAmB,EAAE,GAAG,IAAI,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,EAAA;IAExC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO;AACrC,IAAA,MAAM,IAAI,GAAGC,uBAAe,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;AAC/D,IAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AAC1B;;;;;"}
package/dist/svelte.d.cts CHANGED
@@ -1,9 +1,15 @@
1
1
  /**
2
- * use-scroll-animate - Core Type Definitions
2
+ * motionary - Core Type Definitions
3
3
  * A lightweight, high-performance scroll animation library
4
4
  */
5
- /** Built-in animation presets */
6
- type AnimationPreset = 'fade-in' | 'fade-in-up' | 'fade-in-down' | 'fade-in-left' | 'fade-in-right' | 'zoom-in' | 'zoom-out' | 'flip-x' | 'flip-y' | 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right' | 'bounce' | 'rotate-in' | 'blur-in' | 'skew-in' | 'scale-x' | 'scale-y' | 'shimmer' | 'pulse' | 'swing' | 'scale-up' | 'blur-in-up' | 'flip-up' | 'flip-down' | 'rotate-left' | 'rotate-right' | 'clip-up' | 'clip-down' | 'clip-left' | 'clip-right' | 'clip-circle';
5
+ /** The 33 core presets (always available in `PRESETS`). */
6
+ type CorePreset = 'fade-in' | 'fade-in-up' | 'fade-in-down' | 'fade-in-left' | 'fade-in-right' | 'zoom-in' | 'zoom-out' | 'flip-x' | 'flip-y' | 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right' | 'bounce' | 'rotate-in' | 'blur-in' | 'skew-in' | 'scale-x' | 'scale-y' | 'shimmer' | 'pulse' | 'swing' | 'scale-up' | 'blur-in-up' | 'flip-up' | 'flip-down' | 'rotate-left' | 'rotate-right' | 'clip-up' | 'clip-down' | 'clip-left' | 'clip-right' | 'clip-circle';
7
+ /**
8
+ * Every built-in preset name: the core set plus the 6.1 extended set, which is
9
+ * available once `motionary/presets/extended` is loaded (or after
10
+ * `registerPresets(EXTENDED_PRESETS)`).
11
+ */
12
+ type AnimationPreset = CorePreset | ExtendedPreset;
7
13
  /**
8
14
  * How `onProgress` / `progressVar` progress is measured.
9
15
  * - `'ratio'` (default): the element's visible ratio (IntersectionObserver `intersectionRatio`).
@@ -22,16 +28,24 @@ type ProgressMode = 'ratio' | 'scroll';
22
28
  * since those only mean something for a time-based animation.
23
29
  */
24
30
  type ScrollEngine = 'auto' | 'js' | 'css';
31
+ /** The 6.1 extended presets (`motionary/presets/extended`). */
32
+ type ExtendedPreset = 'fade-in-up-sm' | 'fade-in-down-sm' | 'fade-in-left-sm' | 'fade-in-right-sm' | 'fade-in-up-lg' | 'fade-in-down-lg' | 'fade-in-left-lg' | 'fade-in-right-lg' | 'fade-in-up-left' | 'fade-in-up-right' | 'fade-in-down-left' | 'fade-in-down-right' | 'fade-in-scale' | 'fade-in-half' | 'zoom-in-up' | 'zoom-in-down' | 'zoom-in-left' | 'zoom-in-right' | 'zoom-out-up' | 'zoom-out-down' | 'zoom-out-left' | 'zoom-out-right' | 'zoom-in-big' | 'zoom-out-big' | 'zoom-bounce' | 'zoom-in-rotate' | 'scale-x-left' | 'scale-x-right' | 'scale-y-top' | 'scale-y-bottom' | 'stretch-x' | 'stretch-y' | 'flip-x-reverse' | 'flip-y-reverse' | 'flip-y-full' | 'flip-diagonal' | 'flip-diagonal-reverse' | 'flip-left' | 'flip-right' | 'unfold-down' | 'unfold-up' | 'door-open-left' | 'door-open-right' | 'fold-in' | 'flip-x-bounce' | 'flip-y-bounce' | 'swing-in-top' | 'swing-in-bottom' | 'swing-in-left' | 'swing-in-right' | 'slide-up-spring' | 'slide-down-spring' | 'slide-left-spring' | 'slide-right-spring' | 'slide-up-sm' | 'slide-down-sm' | 'back-in-up' | 'back-in-down' | 'back-in-left' | 'back-in-right' | 'light-speed-in-left' | 'light-speed-in-right' | 'rise-in' | 'sink-in' | 'float-in-up' | 'float-in-down' | 'roll-in-left' | 'roll-in-right' | 'spiral-in' | 'spiral-in-reverse' | 'spin-in' | 'rotate-in-up-left' | 'rotate-in-up-right' | 'rotate-in-down-left' | 'rotate-in-down-right' | 'skew-in-left' | 'skew-in-y' | 'shear-in' | 'shear-in-reverse' | 'twist-in' | 'tilt-in-left' | 'tilt-in-right' | 'blur-in-down' | 'blur-in-left' | 'blur-in-right' | 'blur-in-strong' | 'blur-in-zoom' | 'blur-in-scale' | 'blur-in-x' | 'mask-up' | 'mask-down' | 'mask-left' | 'mask-right' | 'blur-mask-up' | 'clip-circle-top' | 'clip-circle-bottom' | 'clip-circle-left' | 'clip-circle-right' | 'clip-circle-corner' | 'clip-ellipse' | 'clip-diamond' | 'clip-split-x' | 'clip-split-y' | 'clip-box' | 'clip-pill' | 'clip-blinds' | 'clip-blinds-x' | 'clip-diagonal' | 'clip-diagonal-reverse' | 'clip-slant-right' | 'clip-slant-left' | 'bounce-in' | 'bounce-in-up' | 'bounce-in-down' | 'bounce-in-left' | 'bounce-in-right' | 'elastic-in' | 'elastic-in-x' | 'rubber-in' | 'jello-in' | 'wobble-in' | 'tada-in' | 'heartbeat-in' | 'drop-in' | 'pop-in' | 'squash-in' | 'shake-in' | 'swing-in' | 'brightness-in' | 'darken-in' | 'color-in' | 'saturate-in' | 'hue-in' | 'sepia-in' | 'invert-in' | 'contrast-in' | 'exposure-in' | 'vintage-in' | 'blur-bright-in' | 'shadow-lift' | 'neon-glow-in' | 'glow-in' | 'perspective-in-up' | 'perspective-in-down' | 'perspective-in-left' | 'perspective-in-right' | 'depth-push' | 'depth-pull' | 'depth-in-up' | 'swoop-in-left' | 'swoop-in-right' | 'card-tilt-in' | 'glitch-in' | 'glitch-in-color' | 'typewriter' | 'typewriter-lines' | 'hinge-in' | 'flicker-in' | 'scan-in' | 'materialize' | 'teleport-in' | 'stagger-fade-up' | 'stagger-pop' | 'stagger-rise' | 'stagger-slide' | 'stagger-flip' | 'stagger-blur' | 'stagger-zoom' | 'stagger-drop' | 'scrub-parallax-up' | 'scrub-parallax-down' | 'scrub-rotate' | 'scrub-spin' | 'scrub-scale' | 'scrub-shrink' | 'scrub-pan-left' | 'scrub-pan-right' | 'scrub-tilt' | 'scrub-fade-through' | 'scrub-blur-through' | 'scrub-reveal-x';
25
33
  /** Easing function types */
26
34
  type EasingType = 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring' | 'soft-spring' | 'heavy-bounce' | [number, number, number, number] | ((t: number) => number) | string;
27
35
  /** Keyframe definition for custom animations */
28
36
  interface AnimationKeyframe {
29
37
  [property: string]: string | number;
30
38
  }
39
+ /** One intermediate keyframe of a preset: `offset` is 0 < offset < 1. */
40
+ interface AnimationFrame extends AnimationKeyframe {
41
+ offset: number;
42
+ }
31
43
  /** Custom animation definition */
32
44
  interface CustomAnimation {
33
45
  from: AnimationKeyframe;
34
46
  to: AnimationKeyframe;
47
+ /** Optional intermediate keyframes (overshoot, bounce, …), played between `from` and `to`. */
48
+ frames?: AnimationFrame[];
35
49
  }
36
50
  /** Per-element animation options */
37
51
  interface AnimateOptions {
@@ -173,7 +187,7 @@ interface ScrollAnimateInstance {
173
187
  }
174
188
 
175
189
  /**
176
- * use-scroll-animate - Staggered children
190
+ * motionary - Staggered children
177
191
  * Reveal a container's children one after another when the container scrolls
178
192
  * into view, optionally also animating children that are added later.
179
193
  */
@@ -191,13 +205,13 @@ interface StaggerOptions extends AnimateOptions {
191
205
  }
192
206
 
193
207
  /**
194
- * use-scroll-animate - Svelte integration
208
+ * motionary - Svelte integration
195
209
  *
196
210
  * Svelte actions (no import from `svelte` needed, works with Svelte 3, 4 and 5):
197
211
  *
198
212
  * ```svelte
199
213
  * <script>
200
- * import { scrollAnimate, scrollStagger } from 'use-scroll-animate/svelte';
214
+ * import { scrollAnimate, scrollStagger } from 'motionary/svelte';
201
215
  * </script>
202
216
  * <div use:scrollAnimate={{ animation: 'fade-in-up', duration: 800 }}>…</div>
203
217
  * <ul use:scrollStagger={{ stagger: 60 }}>…</ul>
package/dist/svelte.d.ts CHANGED
@@ -1,9 +1,15 @@
1
1
  /**
2
- * use-scroll-animate - Core Type Definitions
2
+ * motionary - Core Type Definitions
3
3
  * A lightweight, high-performance scroll animation library
4
4
  */
5
- /** Built-in animation presets */
6
- type AnimationPreset = 'fade-in' | 'fade-in-up' | 'fade-in-down' | 'fade-in-left' | 'fade-in-right' | 'zoom-in' | 'zoom-out' | 'flip-x' | 'flip-y' | 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right' | 'bounce' | 'rotate-in' | 'blur-in' | 'skew-in' | 'scale-x' | 'scale-y' | 'shimmer' | 'pulse' | 'swing' | 'scale-up' | 'blur-in-up' | 'flip-up' | 'flip-down' | 'rotate-left' | 'rotate-right' | 'clip-up' | 'clip-down' | 'clip-left' | 'clip-right' | 'clip-circle';
5
+ /** The 33 core presets (always available in `PRESETS`). */
6
+ type CorePreset = 'fade-in' | 'fade-in-up' | 'fade-in-down' | 'fade-in-left' | 'fade-in-right' | 'zoom-in' | 'zoom-out' | 'flip-x' | 'flip-y' | 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right' | 'bounce' | 'rotate-in' | 'blur-in' | 'skew-in' | 'scale-x' | 'scale-y' | 'shimmer' | 'pulse' | 'swing' | 'scale-up' | 'blur-in-up' | 'flip-up' | 'flip-down' | 'rotate-left' | 'rotate-right' | 'clip-up' | 'clip-down' | 'clip-left' | 'clip-right' | 'clip-circle';
7
+ /**
8
+ * Every built-in preset name: the core set plus the 6.1 extended set, which is
9
+ * available once `motionary/presets/extended` is loaded (or after
10
+ * `registerPresets(EXTENDED_PRESETS)`).
11
+ */
12
+ type AnimationPreset = CorePreset | ExtendedPreset;
7
13
  /**
8
14
  * How `onProgress` / `progressVar` progress is measured.
9
15
  * - `'ratio'` (default): the element's visible ratio (IntersectionObserver `intersectionRatio`).
@@ -22,16 +28,24 @@ type ProgressMode = 'ratio' | 'scroll';
22
28
  * since those only mean something for a time-based animation.
23
29
  */
24
30
  type ScrollEngine = 'auto' | 'js' | 'css';
31
+ /** The 6.1 extended presets (`motionary/presets/extended`). */
32
+ type ExtendedPreset = 'fade-in-up-sm' | 'fade-in-down-sm' | 'fade-in-left-sm' | 'fade-in-right-sm' | 'fade-in-up-lg' | 'fade-in-down-lg' | 'fade-in-left-lg' | 'fade-in-right-lg' | 'fade-in-up-left' | 'fade-in-up-right' | 'fade-in-down-left' | 'fade-in-down-right' | 'fade-in-scale' | 'fade-in-half' | 'zoom-in-up' | 'zoom-in-down' | 'zoom-in-left' | 'zoom-in-right' | 'zoom-out-up' | 'zoom-out-down' | 'zoom-out-left' | 'zoom-out-right' | 'zoom-in-big' | 'zoom-out-big' | 'zoom-bounce' | 'zoom-in-rotate' | 'scale-x-left' | 'scale-x-right' | 'scale-y-top' | 'scale-y-bottom' | 'stretch-x' | 'stretch-y' | 'flip-x-reverse' | 'flip-y-reverse' | 'flip-y-full' | 'flip-diagonal' | 'flip-diagonal-reverse' | 'flip-left' | 'flip-right' | 'unfold-down' | 'unfold-up' | 'door-open-left' | 'door-open-right' | 'fold-in' | 'flip-x-bounce' | 'flip-y-bounce' | 'swing-in-top' | 'swing-in-bottom' | 'swing-in-left' | 'swing-in-right' | 'slide-up-spring' | 'slide-down-spring' | 'slide-left-spring' | 'slide-right-spring' | 'slide-up-sm' | 'slide-down-sm' | 'back-in-up' | 'back-in-down' | 'back-in-left' | 'back-in-right' | 'light-speed-in-left' | 'light-speed-in-right' | 'rise-in' | 'sink-in' | 'float-in-up' | 'float-in-down' | 'roll-in-left' | 'roll-in-right' | 'spiral-in' | 'spiral-in-reverse' | 'spin-in' | 'rotate-in-up-left' | 'rotate-in-up-right' | 'rotate-in-down-left' | 'rotate-in-down-right' | 'skew-in-left' | 'skew-in-y' | 'shear-in' | 'shear-in-reverse' | 'twist-in' | 'tilt-in-left' | 'tilt-in-right' | 'blur-in-down' | 'blur-in-left' | 'blur-in-right' | 'blur-in-strong' | 'blur-in-zoom' | 'blur-in-scale' | 'blur-in-x' | 'mask-up' | 'mask-down' | 'mask-left' | 'mask-right' | 'blur-mask-up' | 'clip-circle-top' | 'clip-circle-bottom' | 'clip-circle-left' | 'clip-circle-right' | 'clip-circle-corner' | 'clip-ellipse' | 'clip-diamond' | 'clip-split-x' | 'clip-split-y' | 'clip-box' | 'clip-pill' | 'clip-blinds' | 'clip-blinds-x' | 'clip-diagonal' | 'clip-diagonal-reverse' | 'clip-slant-right' | 'clip-slant-left' | 'bounce-in' | 'bounce-in-up' | 'bounce-in-down' | 'bounce-in-left' | 'bounce-in-right' | 'elastic-in' | 'elastic-in-x' | 'rubber-in' | 'jello-in' | 'wobble-in' | 'tada-in' | 'heartbeat-in' | 'drop-in' | 'pop-in' | 'squash-in' | 'shake-in' | 'swing-in' | 'brightness-in' | 'darken-in' | 'color-in' | 'saturate-in' | 'hue-in' | 'sepia-in' | 'invert-in' | 'contrast-in' | 'exposure-in' | 'vintage-in' | 'blur-bright-in' | 'shadow-lift' | 'neon-glow-in' | 'glow-in' | 'perspective-in-up' | 'perspective-in-down' | 'perspective-in-left' | 'perspective-in-right' | 'depth-push' | 'depth-pull' | 'depth-in-up' | 'swoop-in-left' | 'swoop-in-right' | 'card-tilt-in' | 'glitch-in' | 'glitch-in-color' | 'typewriter' | 'typewriter-lines' | 'hinge-in' | 'flicker-in' | 'scan-in' | 'materialize' | 'teleport-in' | 'stagger-fade-up' | 'stagger-pop' | 'stagger-rise' | 'stagger-slide' | 'stagger-flip' | 'stagger-blur' | 'stagger-zoom' | 'stagger-drop' | 'scrub-parallax-up' | 'scrub-parallax-down' | 'scrub-rotate' | 'scrub-spin' | 'scrub-scale' | 'scrub-shrink' | 'scrub-pan-left' | 'scrub-pan-right' | 'scrub-tilt' | 'scrub-fade-through' | 'scrub-blur-through' | 'scrub-reveal-x';
25
33
  /** Easing function types */
26
34
  type EasingType = 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring' | 'soft-spring' | 'heavy-bounce' | [number, number, number, number] | ((t: number) => number) | string;
27
35
  /** Keyframe definition for custom animations */
28
36
  interface AnimationKeyframe {
29
37
  [property: string]: string | number;
30
38
  }
39
+ /** One intermediate keyframe of a preset: `offset` is 0 < offset < 1. */
40
+ interface AnimationFrame extends AnimationKeyframe {
41
+ offset: number;
42
+ }
31
43
  /** Custom animation definition */
32
44
  interface CustomAnimation {
33
45
  from: AnimationKeyframe;
34
46
  to: AnimationKeyframe;
47
+ /** Optional intermediate keyframes (overshoot, bounce, …), played between `from` and `to`. */
48
+ frames?: AnimationFrame[];
35
49
  }
36
50
  /** Per-element animation options */
37
51
  interface AnimateOptions {
@@ -173,7 +187,7 @@ interface ScrollAnimateInstance {
173
187
  }
174
188
 
175
189
  /**
176
- * use-scroll-animate - Staggered children
190
+ * motionary - Staggered children
177
191
  * Reveal a container's children one after another when the container scrolls
178
192
  * into view, optionally also animating children that are added later.
179
193
  */
@@ -191,13 +205,13 @@ interface StaggerOptions extends AnimateOptions {
191
205
  }
192
206
 
193
207
  /**
194
- * use-scroll-animate - Svelte integration
208
+ * motionary - Svelte integration
195
209
  *
196
210
  * Svelte actions (no import from `svelte` needed, works with Svelte 3, 4 and 5):
197
211
  *
198
212
  * ```svelte
199
213
  * <script>
200
- * import { scrollAnimate, scrollStagger } from 'use-scroll-animate/svelte';
214
+ * import { scrollAnimate, scrollStagger } from 'motionary/svelte';
201
215
  * </script>
202
216
  * <div use:scrollAnimate={{ animation: 'fade-in-up', duration: 800 }}>…</div>
203
217
  * <ul use:scrollStagger={{ stagger: 60 }}>…</ul>
package/dist/svelte.js CHANGED
@@ -1,14 +1,15 @@
1
- import { c as createScrollAnimate } from './chunks/core-mV_TPgG_.js';
2
- import { s as staggerChildren } from './chunks/stagger-BFAhKknX.js';
1
+ import { c as createScrollAnimate } from './chunks/core-D7cVumUu.js';
2
+ import { s as staggerChildren } from './chunks/stagger-DtMKo2SK.js';
3
+ import './chunks/presets-BYBVJVeP.js';
3
4
 
4
5
  /**
5
- * use-scroll-animate - Svelte integration
6
+ * motionary - Svelte integration
6
7
  *
7
8
  * Svelte actions (no import from `svelte` needed, works with Svelte 3, 4 and 5):
8
9
  *
9
10
  * ```svelte
10
11
  * <script>
11
- * import { scrollAnimate, scrollStagger } from 'use-scroll-animate/svelte';
12
+ * import { scrollAnimate, scrollStagger } from 'motionary/svelte';
12
13
  * </script>
13
14
  * <div use:scrollAnimate={{ animation: 'fade-in-up', duration: 800 }}>…</div>
14
15
  * <ul use:scrollStagger={{ stagger: 60 }}>…</ul>
@@ -1 +1 @@
1
- {"version":3,"file":"svelte.js","sources":["../src/svelte.ts"],"sourcesContent":["/**\n * use-scroll-animate - Svelte integration\n *\n * Svelte actions (no import from `svelte` needed, works with Svelte 3, 4 and 5):\n *\n * ```svelte\n * <script>\n * import { scrollAnimate, scrollStagger } from 'use-scroll-animate/svelte';\n * </script>\n * <div use:scrollAnimate={{ animation: 'fade-in-up', duration: 800 }}>…</div>\n * <ul use:scrollStagger={{ stagger: 60 }}>…</ul>\n * ```\n */\n\nimport type { AnimateOptions, ScrollAnimateInstance } from './types';\nimport { createScrollAnimate } from './core';\nimport { staggerChildren, type StaggerOptions } from './stagger';\n\nexport interface ScrollAnimateActionOptions extends AnimateOptions {\n /** Instance to register with (default: a shared instance created on first use) */\n instance?: ScrollAnimateInstance;\n}\n\nexport interface ScrollStaggerActionOptions extends StaggerOptions {\n instance?: ScrollAnimateInstance;\n}\n\n/** Shape of a Svelte action's return value. */\nexport interface ActionReturn<P> {\n update?: (parameter: P) => void;\n destroy?: () => void;\n}\n\nlet shared: ScrollAnimateInstance | null = null;\nconst getInstance = (own?: ScrollAnimateInstance) => own || shared || (shared = createScrollAnimate());\n\nconst CALLBACKS = ['onStart', 'onComplete', 'onEnter', 'onLeave', 'onProgress'] as const;\n\n/** Callbacks always call the latest parameter's version. */\nfunction liveCallbacks(opts: AnimateOptions, latest: () => AnimateOptions): AnimateOptions {\n const out: AnimateOptions = { ...opts };\n CALLBACKS.forEach((name) => {\n if (typeof opts[name] === 'function') (out as any)[name] = (...args: unknown[]) => (latest()[name] as any)?.(...args);\n });\n return out;\n}\n\n/**\n * Animate `node` when it scrolls into view. Changing the parameter updates the\n * callbacks right away; other options are applied if the element has not\n * animated yet.\n */\nexport function scrollAnimate(\n node: Element,\n options: ScrollAnimateActionOptions = {}\n): ActionReturn<ScrollAnimateActionOptions | undefined> {\n let current = options;\n const { instance, ...opts } = options;\n const sa = getInstance(instance);\n sa.observe(node, liveCallbacks(opts, () => current));\n\n return {\n update(next = {}) {\n current = next;\n const record = sa.getObservedElements().find((r) => r.element === node);\n if (record && !record.animated) {\n const { instance: _ignored, ...nextOpts } = next;\n sa.unobserve(node);\n sa.observe(node, liveCallbacks(nextOpts, () => current));\n }\n },\n destroy() {\n sa.unobserve(node);\n },\n };\n}\n\n/** Stagger the children of `node` when it scrolls into view (`observeChildren: true` also animates children added later). */\nexport function scrollStagger(\n node: Element,\n options: ScrollStaggerActionOptions = {}\n): ActionReturn<ScrollStaggerActionOptions | undefined> {\n const { instance, ...opts } = options;\n const stop = staggerChildren(node, opts, getInstance(instance));\n return { destroy: stop };\n}\n"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;AAYG;AAqBH,IAAI,MAAM,GAAiC,IAAI;AAC/C,MAAM,WAAW,GAAG,CAAC,GAA2B,KAAK,GAAG,IAAI,MAAM,KAAK,MAAM,GAAG,mBAAmB,EAAE,CAAC;AAEtG,MAAM,SAAS,GAAG,CAAC,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAU;AAExF;AACA,SAAS,aAAa,CAAC,IAAoB,EAAE,MAA4B,EAAA;AACvE,IAAA,MAAM,GAAG,GAAmB,EAAE,GAAG,IAAI,EAAE;AACvC,IAAA,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;AACzB,QAAA,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,UAAU;YAAG,GAAW,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAe,KAAM,MAAM,EAAE,CAAC,IAAI,CAAS,GAAG,GAAG,IAAI,CAAC;AACvH,IAAA,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svelte.js","sources":["../src/svelte.ts"],"sourcesContent":["/**\n * motionary - Svelte integration\n *\n * Svelte actions (no import from `svelte` needed, works with Svelte 3, 4 and 5):\n *\n * ```svelte\n * <script>\n * import { scrollAnimate, scrollStagger } from 'motionary/svelte';\n * </script>\n * <div use:scrollAnimate={{ animation: 'fade-in-up', duration: 800 }}>…</div>\n * <ul use:scrollStagger={{ stagger: 60 }}>…</ul>\n * ```\n */\n\nimport type { AnimateOptions, ScrollAnimateInstance } from './types';\nimport { createScrollAnimate } from './core';\nimport { staggerChildren, type StaggerOptions } from './stagger';\n\nexport interface ScrollAnimateActionOptions extends AnimateOptions {\n /** Instance to register with (default: a shared instance created on first use) */\n instance?: ScrollAnimateInstance;\n}\n\nexport interface ScrollStaggerActionOptions extends StaggerOptions {\n instance?: ScrollAnimateInstance;\n}\n\n/** Shape of a Svelte action's return value. */\nexport interface ActionReturn<P> {\n update?: (parameter: P) => void;\n destroy?: () => void;\n}\n\nlet shared: ScrollAnimateInstance | null = null;\nconst getInstance = (own?: ScrollAnimateInstance) => own || shared || (shared = createScrollAnimate());\n\nconst CALLBACKS = ['onStart', 'onComplete', 'onEnter', 'onLeave', 'onProgress'] as const;\n\n/** Callbacks always call the latest parameter's version. */\nfunction liveCallbacks(opts: AnimateOptions, latest: () => AnimateOptions): AnimateOptions {\n const out: AnimateOptions = { ...opts };\n CALLBACKS.forEach((name) => {\n if (typeof opts[name] === 'function') (out as any)[name] = (...args: unknown[]) => (latest()[name] as any)?.(...args);\n });\n return out;\n}\n\n/**\n * Animate `node` when it scrolls into view. Changing the parameter updates the\n * callbacks right away; other options are applied if the element has not\n * animated yet.\n */\nexport function scrollAnimate(\n node: Element,\n options: ScrollAnimateActionOptions = {}\n): ActionReturn<ScrollAnimateActionOptions | undefined> {\n let current = options;\n const { instance, ...opts } = options;\n const sa = getInstance(instance);\n sa.observe(node, liveCallbacks(opts, () => current));\n\n return {\n update(next = {}) {\n current = next;\n const record = sa.getObservedElements().find((r) => r.element === node);\n if (record && !record.animated) {\n const { instance: _ignored, ...nextOpts } = next;\n sa.unobserve(node);\n sa.observe(node, liveCallbacks(nextOpts, () => current));\n }\n },\n destroy() {\n sa.unobserve(node);\n },\n };\n}\n\n/** Stagger the children of `node` when it scrolls into view (`observeChildren: true` also animates children added later). */\nexport function scrollStagger(\n node: Element,\n options: ScrollStaggerActionOptions = {}\n): ActionReturn<ScrollStaggerActionOptions | undefined> {\n const { instance, ...opts } = options;\n const stop = staggerChildren(node, opts, getInstance(instance));\n return { destroy: stop };\n}\n"],"names":[],"mappings":";;;;AAAA;;;;;;;;;;;;AAYG;AAqBH,IAAI,MAAM,GAAiC,IAAI;AAC/C,MAAM,WAAW,GAAG,CAAC,GAA2B,KAAK,GAAG,IAAI,MAAM,KAAK,MAAM,GAAG,mBAAmB,EAAE,CAAC;AAEtG,MAAM,SAAS,GAAG,CAAC,SAAS,EAAE,YAAY,EAAE,SAAS,EAAE,SAAS,EAAE,YAAY,CAAU;AAExF;AACA,SAAS,aAAa,CAAC,IAAoB,EAAE,MAA4B,EAAA;AACvE,IAAA,MAAM,GAAG,GAAmB,EAAE,GAAG,IAAI,EAAE;AACvC,IAAA,SAAS,CAAC,OAAO,CAAC,CAAC,IAAI,KAAI;AACzB,QAAA,IAAI,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,UAAU;YAAG,GAAW,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,IAAe,KAAM,MAAM,EAAE,CAAC,IAAI,CAAS,GAAG,GAAG,IAAI,CAAC;AACvH,IAAA,CAAC,CAAC;AACF,IAAA,OAAO,GAAG;AACZ;AAEA;;;;AAIG;SACa,aAAa,CAC3B,IAAa,EACb,UAAsC,EAAE,EAAA;IAExC,IAAI,OAAO,GAAG,OAAO;IACrB,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO;AACrC,IAAA,MAAM,EAAE,GAAG,WAAW,CAAC,QAAQ,CAAC;AAChC,IAAA,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,aAAa,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,CAAC;IAEpD,OAAO;QACL,MAAM,CAAC,IAAI,GAAG,EAAE,EAAA;YACd,OAAO,GAAG,IAAI;YACd,MAAM,MAAM,GAAG,EAAE,CAAC,mBAAmB,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,OAAO,KAAK,IAAI,CAAC;AACvE,YAAA,IAAI,MAAM,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE;gBAC9B,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,QAAQ,EAAE,GAAG,IAAI;AAChD,gBAAA,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC;AAClB,gBAAA,EAAE,CAAC,OAAO,CAAC,IAAI,EAAE,aAAa,CAAC,QAAQ,EAAE,MAAM,OAAO,CAAC,CAAC;YAC1D;QACF,CAAC;QACD,OAAO,GAAA;AACL,YAAA,EAAE,CAAC,SAAS,CAAC,IAAI,CAAC;QACpB,CAAC;KACF;AACH;AAEA;SACgB,aAAa,CAC3B,IAAa,EACb,UAAsC,EAAE,EAAA;IAExC,MAAM,EAAE,QAAQ,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO;AACrC,IAAA,MAAM,IAAI,GAAG,eAAe,CAAC,IAAI,EAAE,IAAI,EAAE,WAAW,CAAC,QAAQ,CAAC,CAAC;AAC/D,IAAA,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE;AAC1B;;;;"}
package/dist/vue.cjs CHANGED
@@ -1,10 +1,11 @@
1
1
  'use strict';
2
2
 
3
- var core = require('./chunks/core-qpECfEkb.cjs');
4
- var stagger = require('./chunks/stagger-CLc3j58T.cjs');
3
+ var core = require('./chunks/core-B5T0dhFH.cjs');
4
+ var stagger = require('./chunks/stagger-CCFyhzSw.cjs');
5
+ require('./chunks/presets-CUHys3sK.cjs');
5
6
 
6
7
  /**
7
- * use-scroll-animate - Vue 3 Integration
8
+ * motionary - Vue 3 Integration
8
9
  * Provides useScrollAnimate and useScrollStagger composables for Vue 3 applications.
9
10
  *
10
11
  * A thin wrapper around the core engine, so it shares its behaviour: `once`,
package/dist/vue.cjs.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vue.cjs","sources":["../src/vue.ts"],"sourcesContent":["/**\n * use-scroll-animate - Vue 3 Integration\n * Provides useScrollAnimate and useScrollStagger composables for Vue 3 applications.\n *\n * A thin wrapper around the core engine, so it shares its behaviour: `once`,\n * `offset`, custom easing functions, progress, `prefers-reduced-motion`\n * support, and cleanup on unmount.\n */\n\nimport type { AnimateOptions, ScrollAnimateInstance } from './types';\nimport { createScrollAnimate } from './core';\nimport { staggerChildren, type StaggerOptions } from './stagger';\n\n/** Support refs on components (`$el`) as well as plain elements. */\nfunction unwrap(value: unknown): Element | null {\n if (value && typeof Element !== 'undefined' && !(value instanceof Element) && (value as any).$el instanceof Element) {\n return (value as any).$el as Element;\n }\n return (value as Element | null) || null;\n}\n\nexport function createVueComposables(Vue: {\n ref: <T>(value: T | null) => { value: T | null };\n onMounted: (fn: () => void) => void;\n onUnmounted: (fn: () => void) => void;\n}) {\n // Created lazily on the client so importing on the server is side-effect free.\n let instance: ScrollAnimateInstance | null = null;\n const getInstance = () => instance || (instance = createScrollAnimate());\n\n function useScrollAnimate(options: AnimateOptions = {}) {\n const animateRef = Vue.ref<Element>(null);\n let el: Element | null = null;\n\n Vue.onMounted(() => {\n const target = unwrap(animateRef.value);\n if (!target) return;\n el = target;\n getInstance().observe(el, options);\n });\n\n Vue.onUnmounted(() => {\n if (el) getInstance().unobserve(el);\n el = null;\n });\n\n return { animateRef };\n }\n\n /** Stagger the children of `staggerRef`; `observeChildren: true` also animates children added later. */\n function useScrollStagger(options: StaggerOptions = {}) {\n const staggerRef = Vue.ref<Element>(null);\n let stop: (() => void) | undefined;\n\n Vue.onMounted(() => {\n const target = unwrap(staggerRef.value);\n if (target) stop = staggerChildren(target, options, getInstance());\n });\n\n Vue.onUnmounted(() => {\n stop?.();\n stop = undefined;\n });\n\n return { staggerRef };\n }\n\n return { useScrollAnimate, useScrollStagger };\n}\n"],"names":["createScrollAnimate","staggerChildren"],"mappings":";;;;;AAAA;;;;;;;AAOG;AAMH;AACA,SAAS,MAAM,CAAC,KAAc,EAAA;IAC5B,IAAI,KAAK,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,EAAE,KAAK,YAAY,OAAO,CAAC,IAAK,KAAa,CAAC,GAAG,YAAY,OAAO,EAAE;QACnH,OAAQ,KAAa,CAAC,GAAc;IACtC;IACA,OAAQ,KAAwB,IAAI,IAAI;AAC1C;AAEM,SAAU,oBAAoB,CAAC,GAIpC,EAAA;;IAEC,IAAI,QAAQ,GAAiC,IAAI;AACjD,IAAA,MAAM,WAAW,GAAG,MAAM,QAAQ,KAAK,QAAQ,GAAGA,wBAAmB,EAAE,CAAC;IAExE,SAAS,gBAAgB,CAAC,OAAA,GAA0B,EAAE,EAAA;QACpD,MAAM,UAAU,GAAG,GAAG,CAAC,GAAG,CAAU,IAAI,CAAC;QACzC,IAAI,EAAE,GAAmB,IAAI;AAE7B,QAAA,GAAG,CAAC,SAAS,CAAC,MAAK;YACjB,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC;AACvC,YAAA,IAAI,CAAC,MAAM;gBAAE;YACb,EAAE,GAAG,MAAM;YACX,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC;AACpC,QAAA,CAAC,CAAC;AAEF,QAAA,GAAG,CAAC,WAAW,CAAC,MAAK;AACnB,YAAA,IAAI,EAAE;AAAE,gBAAA,WAAW,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;YACnC,EAAE,GAAG,IAAI;AACX,QAAA,CAAC,CAAC;QAEF,OAAO,EAAE,UAAU,EAAE;IACvB;;IAGA,SAAS,gBAAgB,CAAC,OAAA,GAA0B,EAAE,EAAA;QACpD,MAAM,UAAU,GAAG,GAAG,CAAC,GAAG,CAAU,IAAI,CAAC;AACzC,QAAA,IAAI,IAA8B;AAElC,QAAA,GAAG,CAAC,SAAS,CAAC,MAAK;YACjB,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC;AACvC,YAAA,IAAI,MAAM;gBAAE,IAAI,GAAGC,uBAAe,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AACpE,QAAA,CAAC,CAAC;AAEF,QAAA,GAAG,CAAC,WAAW,CAAC,MAAK;YACnB,IAAI,IAAI;YACR,IAAI,GAAG,SAAS;AAClB,QAAA,CAAC,CAAC;QAEF,OAAO,EAAE,UAAU,EAAE;IACvB;AAEA,IAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE;AAC/C;;;;"}
1
+ {"version":3,"file":"vue.cjs","sources":["../src/vue.ts"],"sourcesContent":["/**\n * motionary - Vue 3 Integration\n * Provides useScrollAnimate and useScrollStagger composables for Vue 3 applications.\n *\n * A thin wrapper around the core engine, so it shares its behaviour: `once`,\n * `offset`, custom easing functions, progress, `prefers-reduced-motion`\n * support, and cleanup on unmount.\n */\n\nimport type { AnimateOptions, ScrollAnimateInstance } from './types';\nimport { createScrollAnimate } from './core';\nimport { staggerChildren, type StaggerOptions } from './stagger';\n\n/** Support refs on components (`$el`) as well as plain elements. */\nfunction unwrap(value: unknown): Element | null {\n if (value && typeof Element !== 'undefined' && !(value instanceof Element) && (value as any).$el instanceof Element) {\n return (value as any).$el as Element;\n }\n return (value as Element | null) || null;\n}\n\nexport function createVueComposables(Vue: {\n ref: <T>(value: T | null) => { value: T | null };\n onMounted: (fn: () => void) => void;\n onUnmounted: (fn: () => void) => void;\n}) {\n // Created lazily on the client so importing on the server is side-effect free.\n let instance: ScrollAnimateInstance | null = null;\n const getInstance = () => instance || (instance = createScrollAnimate());\n\n function useScrollAnimate(options: AnimateOptions = {}) {\n const animateRef = Vue.ref<Element>(null);\n let el: Element | null = null;\n\n Vue.onMounted(() => {\n const target = unwrap(animateRef.value);\n if (!target) return;\n el = target;\n getInstance().observe(el, options);\n });\n\n Vue.onUnmounted(() => {\n if (el) getInstance().unobserve(el);\n el = null;\n });\n\n return { animateRef };\n }\n\n /** Stagger the children of `staggerRef`; `observeChildren: true` also animates children added later. */\n function useScrollStagger(options: StaggerOptions = {}) {\n const staggerRef = Vue.ref<Element>(null);\n let stop: (() => void) | undefined;\n\n Vue.onMounted(() => {\n const target = unwrap(staggerRef.value);\n if (target) stop = staggerChildren(target, options, getInstance());\n });\n\n Vue.onUnmounted(() => {\n stop?.();\n stop = undefined;\n });\n\n return { staggerRef };\n }\n\n return { useScrollAnimate, useScrollStagger };\n}\n"],"names":["createScrollAnimate","staggerChildren"],"mappings":";;;;;;AAAA;;;;;;;AAOG;AAMH;AACA,SAAS,MAAM,CAAC,KAAc,EAAA;IAC5B,IAAI,KAAK,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,EAAE,KAAK,YAAY,OAAO,CAAC,IAAK,KAAa,CAAC,GAAG,YAAY,OAAO,EAAE;QACnH,OAAQ,KAAa,CAAC,GAAc;IACtC;IACA,OAAQ,KAAwB,IAAI,IAAI;AAC1C;AAEM,SAAU,oBAAoB,CAAC,GAIpC,EAAA;;IAEC,IAAI,QAAQ,GAAiC,IAAI;AACjD,IAAA,MAAM,WAAW,GAAG,MAAM,QAAQ,KAAK,QAAQ,GAAGA,wBAAmB,EAAE,CAAC;IAExE,SAAS,gBAAgB,CAAC,OAAA,GAA0B,EAAE,EAAA;QACpD,MAAM,UAAU,GAAG,GAAG,CAAC,GAAG,CAAU,IAAI,CAAC;QACzC,IAAI,EAAE,GAAmB,IAAI;AAE7B,QAAA,GAAG,CAAC,SAAS,CAAC,MAAK;YACjB,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC;AACvC,YAAA,IAAI,CAAC,MAAM;gBAAE;YACb,EAAE,GAAG,MAAM;YACX,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC;AACpC,QAAA,CAAC,CAAC;AAEF,QAAA,GAAG,CAAC,WAAW,CAAC,MAAK;AACnB,YAAA,IAAI,EAAE;AAAE,gBAAA,WAAW,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;YACnC,EAAE,GAAG,IAAI;AACX,QAAA,CAAC,CAAC;QAEF,OAAO,EAAE,UAAU,EAAE;IACvB;;IAGA,SAAS,gBAAgB,CAAC,OAAA,GAA0B,EAAE,EAAA;QACpD,MAAM,UAAU,GAAG,GAAG,CAAC,GAAG,CAAU,IAAI,CAAC;AACzC,QAAA,IAAI,IAA8B;AAElC,QAAA,GAAG,CAAC,SAAS,CAAC,MAAK;YACjB,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC;AACvC,YAAA,IAAI,MAAM;gBAAE,IAAI,GAAGC,uBAAe,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AACpE,QAAA,CAAC,CAAC;AAEF,QAAA,GAAG,CAAC,WAAW,CAAC,MAAK;YACnB,IAAI,IAAI;YACR,IAAI,GAAG,SAAS;AAClB,QAAA,CAAC,CAAC;QAEF,OAAO,EAAE,UAAU,EAAE;IACvB;AAEA,IAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE;AAC/C;;;;"}
package/dist/vue.d.cts CHANGED
@@ -1,9 +1,15 @@
1
1
  /**
2
- * use-scroll-animate - Core Type Definitions
2
+ * motionary - Core Type Definitions
3
3
  * A lightweight, high-performance scroll animation library
4
4
  */
5
- /** Built-in animation presets */
6
- type AnimationPreset = 'fade-in' | 'fade-in-up' | 'fade-in-down' | 'fade-in-left' | 'fade-in-right' | 'zoom-in' | 'zoom-out' | 'flip-x' | 'flip-y' | 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right' | 'bounce' | 'rotate-in' | 'blur-in' | 'skew-in' | 'scale-x' | 'scale-y' | 'shimmer' | 'pulse' | 'swing' | 'scale-up' | 'blur-in-up' | 'flip-up' | 'flip-down' | 'rotate-left' | 'rotate-right' | 'clip-up' | 'clip-down' | 'clip-left' | 'clip-right' | 'clip-circle';
5
+ /** The 33 core presets (always available in `PRESETS`). */
6
+ type CorePreset = 'fade-in' | 'fade-in-up' | 'fade-in-down' | 'fade-in-left' | 'fade-in-right' | 'zoom-in' | 'zoom-out' | 'flip-x' | 'flip-y' | 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right' | 'bounce' | 'rotate-in' | 'blur-in' | 'skew-in' | 'scale-x' | 'scale-y' | 'shimmer' | 'pulse' | 'swing' | 'scale-up' | 'blur-in-up' | 'flip-up' | 'flip-down' | 'rotate-left' | 'rotate-right' | 'clip-up' | 'clip-down' | 'clip-left' | 'clip-right' | 'clip-circle';
7
+ /**
8
+ * Every built-in preset name: the core set plus the 6.1 extended set, which is
9
+ * available once `motionary/presets/extended` is loaded (or after
10
+ * `registerPresets(EXTENDED_PRESETS)`).
11
+ */
12
+ type AnimationPreset = CorePreset | ExtendedPreset;
7
13
  /**
8
14
  * How `onProgress` / `progressVar` progress is measured.
9
15
  * - `'ratio'` (default): the element's visible ratio (IntersectionObserver `intersectionRatio`).
@@ -22,16 +28,24 @@ type ProgressMode = 'ratio' | 'scroll';
22
28
  * since those only mean something for a time-based animation.
23
29
  */
24
30
  type ScrollEngine = 'auto' | 'js' | 'css';
31
+ /** The 6.1 extended presets (`motionary/presets/extended`). */
32
+ type ExtendedPreset = 'fade-in-up-sm' | 'fade-in-down-sm' | 'fade-in-left-sm' | 'fade-in-right-sm' | 'fade-in-up-lg' | 'fade-in-down-lg' | 'fade-in-left-lg' | 'fade-in-right-lg' | 'fade-in-up-left' | 'fade-in-up-right' | 'fade-in-down-left' | 'fade-in-down-right' | 'fade-in-scale' | 'fade-in-half' | 'zoom-in-up' | 'zoom-in-down' | 'zoom-in-left' | 'zoom-in-right' | 'zoom-out-up' | 'zoom-out-down' | 'zoom-out-left' | 'zoom-out-right' | 'zoom-in-big' | 'zoom-out-big' | 'zoom-bounce' | 'zoom-in-rotate' | 'scale-x-left' | 'scale-x-right' | 'scale-y-top' | 'scale-y-bottom' | 'stretch-x' | 'stretch-y' | 'flip-x-reverse' | 'flip-y-reverse' | 'flip-y-full' | 'flip-diagonal' | 'flip-diagonal-reverse' | 'flip-left' | 'flip-right' | 'unfold-down' | 'unfold-up' | 'door-open-left' | 'door-open-right' | 'fold-in' | 'flip-x-bounce' | 'flip-y-bounce' | 'swing-in-top' | 'swing-in-bottom' | 'swing-in-left' | 'swing-in-right' | 'slide-up-spring' | 'slide-down-spring' | 'slide-left-spring' | 'slide-right-spring' | 'slide-up-sm' | 'slide-down-sm' | 'back-in-up' | 'back-in-down' | 'back-in-left' | 'back-in-right' | 'light-speed-in-left' | 'light-speed-in-right' | 'rise-in' | 'sink-in' | 'float-in-up' | 'float-in-down' | 'roll-in-left' | 'roll-in-right' | 'spiral-in' | 'spiral-in-reverse' | 'spin-in' | 'rotate-in-up-left' | 'rotate-in-up-right' | 'rotate-in-down-left' | 'rotate-in-down-right' | 'skew-in-left' | 'skew-in-y' | 'shear-in' | 'shear-in-reverse' | 'twist-in' | 'tilt-in-left' | 'tilt-in-right' | 'blur-in-down' | 'blur-in-left' | 'blur-in-right' | 'blur-in-strong' | 'blur-in-zoom' | 'blur-in-scale' | 'blur-in-x' | 'mask-up' | 'mask-down' | 'mask-left' | 'mask-right' | 'blur-mask-up' | 'clip-circle-top' | 'clip-circle-bottom' | 'clip-circle-left' | 'clip-circle-right' | 'clip-circle-corner' | 'clip-ellipse' | 'clip-diamond' | 'clip-split-x' | 'clip-split-y' | 'clip-box' | 'clip-pill' | 'clip-blinds' | 'clip-blinds-x' | 'clip-diagonal' | 'clip-diagonal-reverse' | 'clip-slant-right' | 'clip-slant-left' | 'bounce-in' | 'bounce-in-up' | 'bounce-in-down' | 'bounce-in-left' | 'bounce-in-right' | 'elastic-in' | 'elastic-in-x' | 'rubber-in' | 'jello-in' | 'wobble-in' | 'tada-in' | 'heartbeat-in' | 'drop-in' | 'pop-in' | 'squash-in' | 'shake-in' | 'swing-in' | 'brightness-in' | 'darken-in' | 'color-in' | 'saturate-in' | 'hue-in' | 'sepia-in' | 'invert-in' | 'contrast-in' | 'exposure-in' | 'vintage-in' | 'blur-bright-in' | 'shadow-lift' | 'neon-glow-in' | 'glow-in' | 'perspective-in-up' | 'perspective-in-down' | 'perspective-in-left' | 'perspective-in-right' | 'depth-push' | 'depth-pull' | 'depth-in-up' | 'swoop-in-left' | 'swoop-in-right' | 'card-tilt-in' | 'glitch-in' | 'glitch-in-color' | 'typewriter' | 'typewriter-lines' | 'hinge-in' | 'flicker-in' | 'scan-in' | 'materialize' | 'teleport-in' | 'stagger-fade-up' | 'stagger-pop' | 'stagger-rise' | 'stagger-slide' | 'stagger-flip' | 'stagger-blur' | 'stagger-zoom' | 'stagger-drop' | 'scrub-parallax-up' | 'scrub-parallax-down' | 'scrub-rotate' | 'scrub-spin' | 'scrub-scale' | 'scrub-shrink' | 'scrub-pan-left' | 'scrub-pan-right' | 'scrub-tilt' | 'scrub-fade-through' | 'scrub-blur-through' | 'scrub-reveal-x';
25
33
  /** Easing function types */
26
34
  type EasingType = 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring' | 'soft-spring' | 'heavy-bounce' | [number, number, number, number] | ((t: number) => number) | string;
27
35
  /** Keyframe definition for custom animations */
28
36
  interface AnimationKeyframe {
29
37
  [property: string]: string | number;
30
38
  }
39
+ /** One intermediate keyframe of a preset: `offset` is 0 < offset < 1. */
40
+ interface AnimationFrame extends AnimationKeyframe {
41
+ offset: number;
42
+ }
31
43
  /** Custom animation definition */
32
44
  interface CustomAnimation {
33
45
  from: AnimationKeyframe;
34
46
  to: AnimationKeyframe;
47
+ /** Optional intermediate keyframes (overshoot, bounce, …), played between `from` and `to`. */
48
+ frames?: AnimationFrame[];
35
49
  }
36
50
  /** Per-element animation options */
37
51
  interface AnimateOptions {
@@ -96,7 +110,7 @@ interface AnimateOptions {
96
110
  }
97
111
 
98
112
  /**
99
- * use-scroll-animate - Staggered children
113
+ * motionary - Staggered children
100
114
  * Reveal a container's children one after another when the container scrolls
101
115
  * into view, optionally also animating children that are added later.
102
116
  */
@@ -114,7 +128,7 @@ interface StaggerOptions extends AnimateOptions {
114
128
  }
115
129
 
116
130
  /**
117
- * use-scroll-animate - Vue 3 Integration
131
+ * motionary - Vue 3 Integration
118
132
  * Provides useScrollAnimate and useScrollStagger composables for Vue 3 applications.
119
133
  *
120
134
  * A thin wrapper around the core engine, so it shares its behaviour: `once`,
package/dist/vue.d.ts CHANGED
@@ -1,9 +1,15 @@
1
1
  /**
2
- * use-scroll-animate - Core Type Definitions
2
+ * motionary - Core Type Definitions
3
3
  * A lightweight, high-performance scroll animation library
4
4
  */
5
- /** Built-in animation presets */
6
- type AnimationPreset = 'fade-in' | 'fade-in-up' | 'fade-in-down' | 'fade-in-left' | 'fade-in-right' | 'zoom-in' | 'zoom-out' | 'flip-x' | 'flip-y' | 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right' | 'bounce' | 'rotate-in' | 'blur-in' | 'skew-in' | 'scale-x' | 'scale-y' | 'shimmer' | 'pulse' | 'swing' | 'scale-up' | 'blur-in-up' | 'flip-up' | 'flip-down' | 'rotate-left' | 'rotate-right' | 'clip-up' | 'clip-down' | 'clip-left' | 'clip-right' | 'clip-circle';
5
+ /** The 33 core presets (always available in `PRESETS`). */
6
+ type CorePreset = 'fade-in' | 'fade-in-up' | 'fade-in-down' | 'fade-in-left' | 'fade-in-right' | 'zoom-in' | 'zoom-out' | 'flip-x' | 'flip-y' | 'slide-up' | 'slide-down' | 'slide-left' | 'slide-right' | 'bounce' | 'rotate-in' | 'blur-in' | 'skew-in' | 'scale-x' | 'scale-y' | 'shimmer' | 'pulse' | 'swing' | 'scale-up' | 'blur-in-up' | 'flip-up' | 'flip-down' | 'rotate-left' | 'rotate-right' | 'clip-up' | 'clip-down' | 'clip-left' | 'clip-right' | 'clip-circle';
7
+ /**
8
+ * Every built-in preset name: the core set plus the 6.1 extended set, which is
9
+ * available once `motionary/presets/extended` is loaded (or after
10
+ * `registerPresets(EXTENDED_PRESETS)`).
11
+ */
12
+ type AnimationPreset = CorePreset | ExtendedPreset;
7
13
  /**
8
14
  * How `onProgress` / `progressVar` progress is measured.
9
15
  * - `'ratio'` (default): the element's visible ratio (IntersectionObserver `intersectionRatio`).
@@ -22,16 +28,24 @@ type ProgressMode = 'ratio' | 'scroll';
22
28
  * since those only mean something for a time-based animation.
23
29
  */
24
30
  type ScrollEngine = 'auto' | 'js' | 'css';
31
+ /** The 6.1 extended presets (`motionary/presets/extended`). */
32
+ type ExtendedPreset = 'fade-in-up-sm' | 'fade-in-down-sm' | 'fade-in-left-sm' | 'fade-in-right-sm' | 'fade-in-up-lg' | 'fade-in-down-lg' | 'fade-in-left-lg' | 'fade-in-right-lg' | 'fade-in-up-left' | 'fade-in-up-right' | 'fade-in-down-left' | 'fade-in-down-right' | 'fade-in-scale' | 'fade-in-half' | 'zoom-in-up' | 'zoom-in-down' | 'zoom-in-left' | 'zoom-in-right' | 'zoom-out-up' | 'zoom-out-down' | 'zoom-out-left' | 'zoom-out-right' | 'zoom-in-big' | 'zoom-out-big' | 'zoom-bounce' | 'zoom-in-rotate' | 'scale-x-left' | 'scale-x-right' | 'scale-y-top' | 'scale-y-bottom' | 'stretch-x' | 'stretch-y' | 'flip-x-reverse' | 'flip-y-reverse' | 'flip-y-full' | 'flip-diagonal' | 'flip-diagonal-reverse' | 'flip-left' | 'flip-right' | 'unfold-down' | 'unfold-up' | 'door-open-left' | 'door-open-right' | 'fold-in' | 'flip-x-bounce' | 'flip-y-bounce' | 'swing-in-top' | 'swing-in-bottom' | 'swing-in-left' | 'swing-in-right' | 'slide-up-spring' | 'slide-down-spring' | 'slide-left-spring' | 'slide-right-spring' | 'slide-up-sm' | 'slide-down-sm' | 'back-in-up' | 'back-in-down' | 'back-in-left' | 'back-in-right' | 'light-speed-in-left' | 'light-speed-in-right' | 'rise-in' | 'sink-in' | 'float-in-up' | 'float-in-down' | 'roll-in-left' | 'roll-in-right' | 'spiral-in' | 'spiral-in-reverse' | 'spin-in' | 'rotate-in-up-left' | 'rotate-in-up-right' | 'rotate-in-down-left' | 'rotate-in-down-right' | 'skew-in-left' | 'skew-in-y' | 'shear-in' | 'shear-in-reverse' | 'twist-in' | 'tilt-in-left' | 'tilt-in-right' | 'blur-in-down' | 'blur-in-left' | 'blur-in-right' | 'blur-in-strong' | 'blur-in-zoom' | 'blur-in-scale' | 'blur-in-x' | 'mask-up' | 'mask-down' | 'mask-left' | 'mask-right' | 'blur-mask-up' | 'clip-circle-top' | 'clip-circle-bottom' | 'clip-circle-left' | 'clip-circle-right' | 'clip-circle-corner' | 'clip-ellipse' | 'clip-diamond' | 'clip-split-x' | 'clip-split-y' | 'clip-box' | 'clip-pill' | 'clip-blinds' | 'clip-blinds-x' | 'clip-diagonal' | 'clip-diagonal-reverse' | 'clip-slant-right' | 'clip-slant-left' | 'bounce-in' | 'bounce-in-up' | 'bounce-in-down' | 'bounce-in-left' | 'bounce-in-right' | 'elastic-in' | 'elastic-in-x' | 'rubber-in' | 'jello-in' | 'wobble-in' | 'tada-in' | 'heartbeat-in' | 'drop-in' | 'pop-in' | 'squash-in' | 'shake-in' | 'swing-in' | 'brightness-in' | 'darken-in' | 'color-in' | 'saturate-in' | 'hue-in' | 'sepia-in' | 'invert-in' | 'contrast-in' | 'exposure-in' | 'vintage-in' | 'blur-bright-in' | 'shadow-lift' | 'neon-glow-in' | 'glow-in' | 'perspective-in-up' | 'perspective-in-down' | 'perspective-in-left' | 'perspective-in-right' | 'depth-push' | 'depth-pull' | 'depth-in-up' | 'swoop-in-left' | 'swoop-in-right' | 'card-tilt-in' | 'glitch-in' | 'glitch-in-color' | 'typewriter' | 'typewriter-lines' | 'hinge-in' | 'flicker-in' | 'scan-in' | 'materialize' | 'teleport-in' | 'stagger-fade-up' | 'stagger-pop' | 'stagger-rise' | 'stagger-slide' | 'stagger-flip' | 'stagger-blur' | 'stagger-zoom' | 'stagger-drop' | 'scrub-parallax-up' | 'scrub-parallax-down' | 'scrub-rotate' | 'scrub-spin' | 'scrub-scale' | 'scrub-shrink' | 'scrub-pan-left' | 'scrub-pan-right' | 'scrub-tilt' | 'scrub-fade-through' | 'scrub-blur-through' | 'scrub-reveal-x';
25
33
  /** Easing function types */
26
34
  type EasingType = 'linear' | 'ease' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring' | 'soft-spring' | 'heavy-bounce' | [number, number, number, number] | ((t: number) => number) | string;
27
35
  /** Keyframe definition for custom animations */
28
36
  interface AnimationKeyframe {
29
37
  [property: string]: string | number;
30
38
  }
39
+ /** One intermediate keyframe of a preset: `offset` is 0 < offset < 1. */
40
+ interface AnimationFrame extends AnimationKeyframe {
41
+ offset: number;
42
+ }
31
43
  /** Custom animation definition */
32
44
  interface CustomAnimation {
33
45
  from: AnimationKeyframe;
34
46
  to: AnimationKeyframe;
47
+ /** Optional intermediate keyframes (overshoot, bounce, …), played between `from` and `to`. */
48
+ frames?: AnimationFrame[];
35
49
  }
36
50
  /** Per-element animation options */
37
51
  interface AnimateOptions {
@@ -96,7 +110,7 @@ interface AnimateOptions {
96
110
  }
97
111
 
98
112
  /**
99
- * use-scroll-animate - Staggered children
113
+ * motionary - Staggered children
100
114
  * Reveal a container's children one after another when the container scrolls
101
115
  * into view, optionally also animating children that are added later.
102
116
  */
@@ -114,7 +128,7 @@ interface StaggerOptions extends AnimateOptions {
114
128
  }
115
129
 
116
130
  /**
117
- * use-scroll-animate - Vue 3 Integration
131
+ * motionary - Vue 3 Integration
118
132
  * Provides useScrollAnimate and useScrollStagger composables for Vue 3 applications.
119
133
  *
120
134
  * A thin wrapper around the core engine, so it shares its behaviour: `once`,
package/dist/vue.js CHANGED
@@ -1,8 +1,9 @@
1
- import { c as createScrollAnimate } from './chunks/core-mV_TPgG_.js';
2
- import { s as staggerChildren } from './chunks/stagger-BFAhKknX.js';
1
+ import { c as createScrollAnimate } from './chunks/core-D7cVumUu.js';
2
+ import { s as staggerChildren } from './chunks/stagger-DtMKo2SK.js';
3
+ import './chunks/presets-BYBVJVeP.js';
3
4
 
4
5
  /**
5
- * use-scroll-animate - Vue 3 Integration
6
+ * motionary - Vue 3 Integration
6
7
  * Provides useScrollAnimate and useScrollStagger composables for Vue 3 applications.
7
8
  *
8
9
  * A thin wrapper around the core engine, so it shares its behaviour: `once`,
package/dist/vue.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"vue.js","sources":["../src/vue.ts"],"sourcesContent":["/**\n * use-scroll-animate - Vue 3 Integration\n * Provides useScrollAnimate and useScrollStagger composables for Vue 3 applications.\n *\n * A thin wrapper around the core engine, so it shares its behaviour: `once`,\n * `offset`, custom easing functions, progress, `prefers-reduced-motion`\n * support, and cleanup on unmount.\n */\n\nimport type { AnimateOptions, ScrollAnimateInstance } from './types';\nimport { createScrollAnimate } from './core';\nimport { staggerChildren, type StaggerOptions } from './stagger';\n\n/** Support refs on components (`$el`) as well as plain elements. */\nfunction unwrap(value: unknown): Element | null {\n if (value && typeof Element !== 'undefined' && !(value instanceof Element) && (value as any).$el instanceof Element) {\n return (value as any).$el as Element;\n }\n return (value as Element | null) || null;\n}\n\nexport function createVueComposables(Vue: {\n ref: <T>(value: T | null) => { value: T | null };\n onMounted: (fn: () => void) => void;\n onUnmounted: (fn: () => void) => void;\n}) {\n // Created lazily on the client so importing on the server is side-effect free.\n let instance: ScrollAnimateInstance | null = null;\n const getInstance = () => instance || (instance = createScrollAnimate());\n\n function useScrollAnimate(options: AnimateOptions = {}) {\n const animateRef = Vue.ref<Element>(null);\n let el: Element | null = null;\n\n Vue.onMounted(() => {\n const target = unwrap(animateRef.value);\n if (!target) return;\n el = target;\n getInstance().observe(el, options);\n });\n\n Vue.onUnmounted(() => {\n if (el) getInstance().unobserve(el);\n el = null;\n });\n\n return { animateRef };\n }\n\n /** Stagger the children of `staggerRef`; `observeChildren: true` also animates children added later. */\n function useScrollStagger(options: StaggerOptions = {}) {\n const staggerRef = Vue.ref<Element>(null);\n let stop: (() => void) | undefined;\n\n Vue.onMounted(() => {\n const target = unwrap(staggerRef.value);\n if (target) stop = staggerChildren(target, options, getInstance());\n });\n\n Vue.onUnmounted(() => {\n stop?.();\n stop = undefined;\n });\n\n return { staggerRef };\n }\n\n return { useScrollAnimate, useScrollStagger };\n}\n"],"names":[],"mappings":";;;AAAA;;;;;;;AAOG;AAMH;AACA,SAAS,MAAM,CAAC,KAAc,EAAA;IAC5B,IAAI,KAAK,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,EAAE,KAAK,YAAY,OAAO,CAAC,IAAK,KAAa,CAAC,GAAG,YAAY,OAAO,EAAE;QACnH,OAAQ,KAAa,CAAC,GAAc;IACtC;IACA,OAAQ,KAAwB,IAAI,IAAI;AAC1C;AAEM,SAAU,oBAAoB,CAAC,GAIpC,EAAA;;IAEC,IAAI,QAAQ,GAAiC,IAAI;AACjD,IAAA,MAAM,WAAW,GAAG,MAAM,QAAQ,KAAK,QAAQ,GAAG,mBAAmB,EAAE,CAAC;IAExE,SAAS,gBAAgB,CAAC,OAAA,GAA0B,EAAE,EAAA;QACpD,MAAM,UAAU,GAAG,GAAG,CAAC,GAAG,CAAU,IAAI,CAAC;QACzC,IAAI,EAAE,GAAmB,IAAI;AAE7B,QAAA,GAAG,CAAC,SAAS,CAAC,MAAK;YACjB,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC;AACvC,YAAA,IAAI,CAAC,MAAM;gBAAE;YACb,EAAE,GAAG,MAAM;YACX,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC;AACpC,QAAA,CAAC,CAAC;AAEF,QAAA,GAAG,CAAC,WAAW,CAAC,MAAK;AACnB,YAAA,IAAI,EAAE;AAAE,gBAAA,WAAW,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;YACnC,EAAE,GAAG,IAAI;AACX,QAAA,CAAC,CAAC;QAEF,OAAO,EAAE,UAAU,EAAE;IACvB;;IAGA,SAAS,gBAAgB,CAAC,OAAA,GAA0B,EAAE,EAAA;QACpD,MAAM,UAAU,GAAG,GAAG,CAAC,GAAG,CAAU,IAAI,CAAC;AACzC,QAAA,IAAI,IAA8B;AAElC,QAAA,GAAG,CAAC,SAAS,CAAC,MAAK;YACjB,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC;AACvC,YAAA,IAAI,MAAM;gBAAE,IAAI,GAAG,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AACpE,QAAA,CAAC,CAAC;AAEF,QAAA,GAAG,CAAC,WAAW,CAAC,MAAK;YACnB,IAAI,IAAI;YACR,IAAI,GAAG,SAAS;AAClB,QAAA,CAAC,CAAC;QAEF,OAAO,EAAE,UAAU,EAAE;IACvB;AAEA,IAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE;AAC/C;;;;"}
1
+ {"version":3,"file":"vue.js","sources":["../src/vue.ts"],"sourcesContent":["/**\n * motionary - Vue 3 Integration\n * Provides useScrollAnimate and useScrollStagger composables for Vue 3 applications.\n *\n * A thin wrapper around the core engine, so it shares its behaviour: `once`,\n * `offset`, custom easing functions, progress, `prefers-reduced-motion`\n * support, and cleanup on unmount.\n */\n\nimport type { AnimateOptions, ScrollAnimateInstance } from './types';\nimport { createScrollAnimate } from './core';\nimport { staggerChildren, type StaggerOptions } from './stagger';\n\n/** Support refs on components (`$el`) as well as plain elements. */\nfunction unwrap(value: unknown): Element | null {\n if (value && typeof Element !== 'undefined' && !(value instanceof Element) && (value as any).$el instanceof Element) {\n return (value as any).$el as Element;\n }\n return (value as Element | null) || null;\n}\n\nexport function createVueComposables(Vue: {\n ref: <T>(value: T | null) => { value: T | null };\n onMounted: (fn: () => void) => void;\n onUnmounted: (fn: () => void) => void;\n}) {\n // Created lazily on the client so importing on the server is side-effect free.\n let instance: ScrollAnimateInstance | null = null;\n const getInstance = () => instance || (instance = createScrollAnimate());\n\n function useScrollAnimate(options: AnimateOptions = {}) {\n const animateRef = Vue.ref<Element>(null);\n let el: Element | null = null;\n\n Vue.onMounted(() => {\n const target = unwrap(animateRef.value);\n if (!target) return;\n el = target;\n getInstance().observe(el, options);\n });\n\n Vue.onUnmounted(() => {\n if (el) getInstance().unobserve(el);\n el = null;\n });\n\n return { animateRef };\n }\n\n /** Stagger the children of `staggerRef`; `observeChildren: true` also animates children added later. */\n function useScrollStagger(options: StaggerOptions = {}) {\n const staggerRef = Vue.ref<Element>(null);\n let stop: (() => void) | undefined;\n\n Vue.onMounted(() => {\n const target = unwrap(staggerRef.value);\n if (target) stop = staggerChildren(target, options, getInstance());\n });\n\n Vue.onUnmounted(() => {\n stop?.();\n stop = undefined;\n });\n\n return { staggerRef };\n }\n\n return { useScrollAnimate, useScrollStagger };\n}\n"],"names":[],"mappings":";;;;AAAA;;;;;;;AAOG;AAMH;AACA,SAAS,MAAM,CAAC,KAAc,EAAA;IAC5B,IAAI,KAAK,IAAI,OAAO,OAAO,KAAK,WAAW,IAAI,EAAE,KAAK,YAAY,OAAO,CAAC,IAAK,KAAa,CAAC,GAAG,YAAY,OAAO,EAAE;QACnH,OAAQ,KAAa,CAAC,GAAc;IACtC;IACA,OAAQ,KAAwB,IAAI,IAAI;AAC1C;AAEM,SAAU,oBAAoB,CAAC,GAIpC,EAAA;;IAEC,IAAI,QAAQ,GAAiC,IAAI;AACjD,IAAA,MAAM,WAAW,GAAG,MAAM,QAAQ,KAAK,QAAQ,GAAG,mBAAmB,EAAE,CAAC;IAExE,SAAS,gBAAgB,CAAC,OAAA,GAA0B,EAAE,EAAA;QACpD,MAAM,UAAU,GAAG,GAAG,CAAC,GAAG,CAAU,IAAI,CAAC;QACzC,IAAI,EAAE,GAAmB,IAAI;AAE7B,QAAA,GAAG,CAAC,SAAS,CAAC,MAAK;YACjB,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC;AACvC,YAAA,IAAI,CAAC,MAAM;gBAAE;YACb,EAAE,GAAG,MAAM;YACX,WAAW,EAAE,CAAC,OAAO,CAAC,EAAE,EAAE,OAAO,CAAC;AACpC,QAAA,CAAC,CAAC;AAEF,QAAA,GAAG,CAAC,WAAW,CAAC,MAAK;AACnB,YAAA,IAAI,EAAE;AAAE,gBAAA,WAAW,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC;YACnC,EAAE,GAAG,IAAI;AACX,QAAA,CAAC,CAAC;QAEF,OAAO,EAAE,UAAU,EAAE;IACvB;;IAGA,SAAS,gBAAgB,CAAC,OAAA,GAA0B,EAAE,EAAA;QACpD,MAAM,UAAU,GAAG,GAAG,CAAC,GAAG,CAAU,IAAI,CAAC;AACzC,QAAA,IAAI,IAA8B;AAElC,QAAA,GAAG,CAAC,SAAS,CAAC,MAAK;YACjB,MAAM,MAAM,GAAG,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC;AACvC,YAAA,IAAI,MAAM;gBAAE,IAAI,GAAG,eAAe,CAAC,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,CAAC;AACpE,QAAA,CAAC,CAAC;AAEF,QAAA,GAAG,CAAC,WAAW,CAAC,MAAK;YACnB,IAAI,IAAI;YACR,IAAI,GAAG,SAAS;AAClB,QAAA,CAAC,CAAC;QAEF,OAAO,EAAE,UAAU,EAAE;IACvB;AAEA,IAAA,OAAO,EAAE,gBAAgB,EAAE,gBAAgB,EAAE;AAC/C;;;;"}
package/docs/API.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # API reference
2
2
 
3
- `use-scroll-animate` — every public export, option and attribute. See the [README](../README.md) for a tour, the [demo](../demo/index.html) to try every preset, and the migration guides for [AOS](./migration-from-aos.md) and [GSAP ScrollTrigger](./migration-from-gsap-scrolltrigger.md). Upgrading from 1.x: see [Upgrading to 2.0](./deprecations.md).
3
+ `motionary` — every public export, option and attribute. See the [README](../README.md) for a tour, the [demo](../demo/index.html) to try every preset, and the migration guides for [AOS](./migration-from-aos.md) and [GSAP ScrollTrigger](./migration-from-gsap-scrolltrigger.md). Upgrading from 1.x: see [Upgrading to 2.0](./deprecations.md).
4
4
 
5
5
  - [Entry points](#entry-points)
6
6
  - [Default instance & `createScrollAnimate(config)`](#default-instance--createscrollanimateconfig)
@@ -17,23 +17,24 @@
17
17
 
18
18
  | Import | Contents |
19
19
  |---|---|
20
- | `use-scroll-animate` | Default instance, `createScrollAnimate`, `staggerChildren`, `timeline`, `parallax`, `getScrollProgress`, `supportsScrollTimeline`, `PRESETS`, `resolvePreset`, `resolveEasing`, `EASING_MAP`, all types |
21
- | `use-scroll-animate/react` | `createReactHooks(React)` |
22
- | `use-scroll-animate/vue` | `createVueComposables({ ref, onMounted, onUnmounted })` |
23
- | `use-scroll-animate/svelte` | `scrollAnimate`, `scrollStagger` actions |
24
- | `use-scroll-animate/solid` | `scrollAnimate`, `scrollStagger` directives, `useScrollAnimate()` (needs `solid-js`) |
25
- | `use-scroll-animate/element` | `defineScrollAnimate(tagName?, instance?)` for `<scroll-animate>` |
20
+ | `motionary` | Default instance, `createScrollAnimate`, `staggerChildren`, `timeline`, `parallax`, `getScrollProgress`, `supportsScrollTimeline`, `PRESETS`, `registerPresets`, `reversePreset`, `resolvePreset`, `resolveEasing`, `EASING_MAP`, all types |
21
+ | `motionary/presets/extended` | Registers the 181 extended presets on import (6.1). Exports `EXTENDED_PRESETS`, `EXTENDED_PRESET_CATEGORIES`, `registerExtendedPresets()`. `<script>`: `dist/presets-extended.umd.js` (global `ScrollAnimatePresets`) |
22
+ | `motionary/react` | `createReactHooks(React)` |
23
+ | `motionary/vue` | `createVueComposables({ ref, onMounted, onUnmounted })` |
24
+ | `motionary/svelte` | `scrollAnimate`, `scrollStagger` actions |
25
+ | `motionary/solid` | `scrollAnimate`, `scrollStagger` directives, `useScrollAnimate()` (needs `solid-js`) |
26
+ | `motionary/element` | `defineScrollAnimate(tagName?, instance?)` for `<scroll-animate>` |
26
27
  | `dist/index.umd.js` | Global `ScrollAnimate` (`ScrollAnimate.default` is the instance, other exports as properties) |
27
28
  | `dist/element.umd.js` | Registers `<scroll-animate>` on load; global `ScrollAnimateElement` |
28
- | `use-scroll-animate/components` (+ `/components/reveal`, `/text`, `/interaction`, `/feedback`, `/background`, `/transitions`) | 30 animated `<usa-*>` Web Components, `defineComponents()`, `configureComponents()`, `toast()`, `viewTransition()`, `flip()` — see **[components.md](./components.md)** |
29
- | `dist/components.umd.js`, `use-scroll-animate/components.css` | Registers every `<usa-*>` on load (global `UsaComponents`); the component styles as a file |
29
+ | `motionary/components` (+ `/components/reveal`, `/text`, `/interaction`, `/feedback`, `/background`, `/transitions`) | 30 animated `<usa-*>` Web Components, `defineComponents()`, `configureComponents()`, `toast()`, `viewTransition()`, `flip()` — see **[components.md](./components.md)** |
30
+ | `dist/components.umd.js`, `motionary/components.css` | Registers every `<usa-*>` on load (global `UsaComponents`); the component styles as a file |
30
31
 
31
32
  Every entry is ESM-first (`import` → `.js` + `.d.ts`) with a CommonJS build (`require` → `.cjs` + `.d.cts`), SSR-safe (no DOM access at import), and has zero runtime dependencies.
32
33
 
33
34
  ## Default instance & `createScrollAnimate(config)`
34
35
 
35
36
  ```ts
36
- import ScrollAnimate, { createScrollAnimate } from 'use-scroll-animate';
37
+ import ScrollAnimate, { createScrollAnimate } from 'motionary';
37
38
 
38
39
  ScrollAnimate.init(); // shared default instance
39
40
  const sa = createScrollAnimate({ defaultDuration: 800, defaultEngine: 'auto' }); // isolated instance
@@ -102,7 +103,11 @@ Boolean attributes are true when present unless their value is `"false"`.
102
103
 
103
104
  ## Presets & easings
104
105
 
105
- `PRESETS` (`Record<AnimationPreset, { from, to }>`): `fade-in`, `fade-in-up`, `fade-in-down`, `fade-in-left`, `fade-in-right`, `zoom-in`, `zoom-out`, `scale-up`, `flip-x`, `flip-y`, `flip-up`, `flip-down`, `slide-up`, `slide-down`, `slide-left`, `slide-right`, `bounce`, `rotate-in`, `rotate-left`, `rotate-right`, `blur-in`, `blur-in-up`, `skew-in`, `scale-x`, `scale-y`, `clip-up`, `clip-down`, `clip-left`, `clip-right`, `clip-circle`, `shimmer`, `pulse`, `swing`.
106
+ `PRESETS` (`{ from, to, frames? }` by name) — the 33 core presets: `fade-in`, `fade-in-up`, `fade-in-down`, `fade-in-left`, `fade-in-right`, `zoom-in`, `zoom-out`, `scale-up`, `flip-x`, `flip-y`, `flip-up`, `flip-down`, `slide-up`, `slide-down`, `slide-left`, `slide-right`, `bounce`, `rotate-in`, `rotate-left`, `rotate-right`, `blur-in`, `blur-in-up`, `skew-in`, `scale-x`, `scale-y`, `clip-up`, `clip-down`, `clip-left`, `clip-right`, `clip-circle`, `shimmer`, `pulse`, `swing`.
107
+
108
+ **Extended presets (6.1)** — 181 more after `import 'motionary/presets/extended'` (or the `dist/presets-extended.umd.js` script); full list by category with keyframes in [presets.md](./presets.md). `PRESETS` is one table per page shared through `Symbol.for('use-scroll-animate.presets')`, so the ESM entries, the UMD bundle and `<usa-reveal effect>` / `<usa-stagger effect>` all see every registered preset.
109
+
110
+ `registerPresets({ name: { from, to, frames? } })` adds or replaces presets (usable by name everywhere). `frames` are intermediate keyframes with `offset` 0–1 (exclusive) played between `from` and `to`; a keyframe may carry its own `easing` (e.g. `steps(16, end)`). Presets combined in an array use only `from` / `to`. `reversePreset(p)` returns the same keyframes backwards (used by `exit`). Scroll-linked `scrub-*` presets are meant for `{ engine: 'css', viewRange: ['cover 0%', 'cover 100%'] }`.
106
111
 
107
112
  `EASING_MAP`: `linear`, `ease`, `ease-in`, `ease-out`, `ease-in-out`, `spring`, `soft-spring`, `heavy-bounce`. `resolvePreset(animation)` and `resolveEasing(easing)` expose the resolution used internally.
108
113
 
@@ -112,7 +117,7 @@ Boolean attributes are true when present unless their value is `"false"`.
112
117
  Reveal the children of `container` one after another when it enters. `StaggerOptions` = `AnimateOptions` + `stagger` (default `80` ms) + `observeChildren` (MutationObserver for children added later). Stopping before the reveal makes the children visible.
113
118
 
114
119
  ### `timeline(options?)` → `Timeline` (4.0; replaces `sequence()`)
115
- One playhead for many WAAPI animations. `options` = `{ defaults: { duration = 600, easing, stagger }, speed, onUpdate(p), onComplete() }`. Build with `.to(target, keyframes | preset, { at, duration, easing, stagger })`, `.label(name, at?)`, `.call(fn, at?)`; positions `'>'` (default), `'<'`, `'-=ms'`, `'+=ms'`, `'<+=ms'`, `'label+=ms'` or ms (`resolvePosition()`). Control: `play(from?)` / `reverse()` (Promises), `pause()`, `seek(ms | label)`, `progress(p?)`, `scrub(el, { source: 'view' | 'scroll', engine: 'auto' | 'native' | 'js', axis, offset, smooth })` → stop (with `.native`), `cancel()`; read `duration`, `time`, `labels`. Presets: `TIMELINE_PRESETS`. Reduced motion jumps to the end. Also in `use-scroll-animate/components/timeline` with `<usa-timeline>`.
120
+ One playhead for many WAAPI animations. `options` = `{ defaults: { duration = 600, easing, stagger }, speed, onUpdate(p), onComplete() }`. Build with `.to(target, keyframes | preset, { at, duration, easing, stagger })`, `.label(name, at?)`, `.call(fn, at?)`; positions `'>'` (default), `'<'`, `'-=ms'`, `'+=ms'`, `'<+=ms'`, `'label+=ms'` or ms (`resolvePosition()`). Control: `play(from?)` / `reverse()` (Promises), `pause()`, `seek(ms | label)`, `progress(p?)`, `scrub(el, { source: 'view' | 'scroll', engine: 'auto' | 'native' | 'js', axis, offset, smooth })` → stop (with `.native`), `cancel()`; read `duration`, `time`, `labels`. Presets: `TIMELINE_PRESETS`. Reduced motion jumps to the end. Also in `motionary/components/timeline` with `<usa-timeline>`.
116
121
 
117
122
  **4.1 — native scrub.** `scrub()` runs on the browser's `ViewTimeline` (default, range `cover`) or `ScrollTimeline` (`{ source: 'scroll' }`, the element is the scroll container) when available, so the playhead is driven off the main thread; each step becomes one scroll-driven animation over its slice of the range. It falls back to a rAF-throttled scroll listener without support, and whenever JS is needed: `smooth`, `offset`, `call()` cues, `onUpdate`, or `engine: 'js'`. `supportsNativeScrub(source?)` reports support. `<usa-timeline scrub>` uses it too (`data-native` is set; `scrub="scroll"`, `smooth`; 5.0 removed `scrub="js"`).
118
123