motionary 0.0.0-stage → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +803 -0
- package/LICENSE +21 -0
- package/README.md +218 -2
- package/README_ja.md +219 -0
- package/README_zh.md +219 -0
- package/bin/usa-codemod-5.mjs +79 -0
- package/bin/usa-codemod-6.mjs +146 -0
- package/dist/chunks/base-BaQV-2ha.cjs +436 -0
- package/dist/chunks/base-BaQV-2ha.cjs.map +1 -0
- package/dist/chunks/base-C_3cAoRz.js +404 -0
- package/dist/chunks/base-C_3cAoRz.js.map +1 -0
- package/dist/chunks/bind-B_CTL6Qn.js +22 -0
- package/dist/chunks/bind-B_CTL6Qn.js.map +1 -0
- package/dist/chunks/bind-Ui43-n2d.cjs +25 -0
- package/dist/chunks/bind-Ui43-n2d.cjs.map +1 -0
- package/dist/chunks/core-B5T0dhFH.cjs +920 -0
- package/dist/chunks/core-B5T0dhFH.cjs.map +1 -0
- package/dist/chunks/core-BGAyaY6L.cjs +265 -0
- package/dist/chunks/core-BGAyaY6L.cjs.map +1 -0
- package/dist/chunks/core-D7cVumUu.js +909 -0
- package/dist/chunks/core-D7cVumUu.js.map +1 -0
- package/dist/chunks/core-VEBw36QK.js +260 -0
- package/dist/chunks/core-VEBw36QK.js.map +1 -0
- package/dist/chunks/core-ps8uvYuN.js +181 -0
- package/dist/chunks/core-ps8uvYuN.js.map +1 -0
- package/dist/chunks/core-zq17EeCI.cjs +185 -0
- package/dist/chunks/core-zq17EeCI.cjs.map +1 -0
- package/dist/chunks/fx-Bs6IrV4Q.js +109 -0
- package/dist/chunks/fx-Bs6IrV4Q.js.map +1 -0
- package/dist/chunks/fx-lBGVtQO1.cjs +114 -0
- package/dist/chunks/fx-lBGVtQO1.cjs.map +1 -0
- package/dist/chunks/generative-D2YyhaeO.js +336 -0
- package/dist/chunks/generative-D2YyhaeO.js.map +1 -0
- package/dist/chunks/generative-DzIZq-_g.cjs +348 -0
- package/dist/chunks/generative-DzIZq-_g.cjs.map +1 -0
- package/dist/chunks/gpu-Bu7qwugO.js +380 -0
- package/dist/chunks/gpu-Bu7qwugO.js.map +1 -0
- package/dist/chunks/gpu-CenK2l6b.cjs +387 -0
- package/dist/chunks/gpu-CenK2l6b.cjs.map +1 -0
- package/dist/chunks/index-tags-DucKMQr_.js +26 -0
- package/dist/chunks/index-tags-DucKMQr_.js.map +1 -0
- package/dist/chunks/index-tags-wv0R_vkO.cjs +28 -0
- package/dist/chunks/index-tags-wv0R_vkO.cjs.map +1 -0
- package/dist/chunks/presets-BYBVJVeP.js +226 -0
- package/dist/chunks/presets-BYBVJVeP.js.map +1 -0
- package/dist/chunks/presets-CUHys3sK.cjs +233 -0
- package/dist/chunks/presets-CUHys3sK.cjs.map +1 -0
- package/dist/chunks/registry-CKNLQpwd.js +121 -0
- package/dist/chunks/registry-CKNLQpwd.js.map +1 -0
- package/dist/chunks/registry-DehBVRDV.cjs +131 -0
- package/dist/chunks/registry-DehBVRDV.cjs.map +1 -0
- package/dist/chunks/spring-CbvHfVtP.js +219 -0
- package/dist/chunks/spring-CbvHfVtP.js.map +1 -0
- package/dist/chunks/spring-Dgx187Vh.cjs +232 -0
- package/dist/chunks/spring-Dgx187Vh.cjs.map +1 -0
- package/dist/chunks/stagger-CCFyhzSw.cjs +86 -0
- package/dist/chunks/stagger-CCFyhzSw.cjs.map +1 -0
- package/dist/chunks/stagger-DtMKo2SK.js +84 -0
- package/dist/chunks/stagger-DtMKo2SK.js.map +1 -0
- package/dist/chunks/variants-BhjyddG8.cjs +39 -0
- package/dist/chunks/variants-BhjyddG8.cjs.map +1 -0
- package/dist/chunks/variants-DRlKVHvu.js +35 -0
- package/dist/chunks/variants-DRlKVHvu.js.map +1 -0
- package/dist/components/a11y.cjs +276 -0
- package/dist/components/a11y.cjs.map +1 -0
- package/dist/components/a11y.d.cts +131 -0
- package/dist/components/a11y.d.ts +131 -0
- package/dist/components/a11y.js +259 -0
- package/dist/components/a11y.js.map +1 -0
- package/dist/components/angular.cjs +76 -0
- package/dist/components/angular.cjs.map +1 -0
- package/dist/components/angular.d.cts +1734 -0
- package/dist/components/angular.d.ts +1734 -0
- package/dist/components/angular.js +70 -0
- package/dist/components/angular.js.map +1 -0
- package/dist/components/background.cjs +659 -0
- package/dist/components/background.cjs.map +1 -0
- package/dist/components/background.css +9 -0
- package/dist/components/background.d.cts +166 -0
- package/dist/components/background.d.ts +166 -0
- package/dist/components/background.js +647 -0
- package/dist/components/background.js.map +1 -0
- package/dist/components/bridge.cjs +154 -0
- package/dist/components/bridge.cjs.map +1 -0
- package/dist/components/bridge.d.cts +63 -0
- package/dist/components/bridge.d.ts +63 -0
- package/dist/components/bridge.js +147 -0
- package/dist/components/bridge.js.map +1 -0
- package/dist/components/cards.cjs +561 -0
- package/dist/components/cards.cjs.map +1 -0
- package/dist/components/cards.css +6 -0
- package/dist/components/cards.d.cts +115 -0
- package/dist/components/cards.d.ts +115 -0
- package/dist/components/cards.js +554 -0
- package/dist/components/cards.js.map +1 -0
- package/dist/components/click.cjs +877 -0
- package/dist/components/click.cjs.map +1 -0
- package/dist/components/click.css +9 -0
- package/dist/components/click.d.cts +218 -0
- package/dist/components/click.d.ts +218 -0
- package/dist/components/click.js +863 -0
- package/dist/components/click.js.map +1 -0
- package/dist/components/depth.cjs +250 -0
- package/dist/components/depth.cjs.map +1 -0
- package/dist/components/depth.css +3 -0
- package/dist/components/depth.d.cts +86 -0
- package/dist/components/depth.d.ts +86 -0
- package/dist/components/depth.js +242 -0
- package/dist/components/depth.js.map +1 -0
- package/dist/components/effects.cjs +2258 -0
- package/dist/components/effects.cjs.map +1 -0
- package/dist/components/effects.d.cts +545 -0
- package/dist/components/effects.d.ts +545 -0
- package/dist/components/effects.js +2200 -0
- package/dist/components/effects.js.map +1 -0
- package/dist/components/feedback.cjs +442 -0
- package/dist/components/feedback.cjs.map +1 -0
- package/dist/components/feedback.css +7 -0
- package/dist/components/feedback.d.cts +144 -0
- package/dist/components/feedback.d.ts +144 -0
- package/dist/components/feedback.js +433 -0
- package/dist/components/feedback.js.map +1 -0
- package/dist/components/fx-gpu.cjs +12 -0
- package/dist/components/fx-gpu.cjs.map +1 -0
- package/dist/components/fx-gpu.d.cts +63 -0
- package/dist/components/fx-gpu.d.ts +63 -0
- package/dist/components/fx-gpu.js +5 -0
- package/dist/components/fx-gpu.js.map +1 -0
- package/dist/components/fx.cjs +169 -0
- package/dist/components/fx.cjs.map +1 -0
- package/dist/components/fx.css +3 -0
- package/dist/components/fx.d.cts +114 -0
- package/dist/components/fx.d.ts +114 -0
- package/dist/components/fx.js +156 -0
- package/dist/components/fx.js.map +1 -0
- package/dist/components/fx2.cjs +25 -0
- package/dist/components/fx2.cjs.map +1 -0
- package/dist/components/fx2.d.cts +136 -0
- package/dist/components/fx2.d.ts +136 -0
- package/dist/components/fx2.js +17 -0
- package/dist/components/fx2.js.map +1 -0
- package/dist/components/gesture.cjs +209 -0
- package/dist/components/gesture.cjs.map +1 -0
- package/dist/components/gesture.css +3 -0
- package/dist/components/gesture.d.cts +134 -0
- package/dist/components/gesture.d.ts +134 -0
- package/dist/components/gesture.js +203 -0
- package/dist/components/gesture.js.map +1 -0
- package/dist/components/interaction.cjs +424 -0
- package/dist/components/interaction.cjs.map +1 -0
- package/dist/components/interaction.css +8 -0
- package/dist/components/interaction.d.cts +115 -0
- package/dist/components/interaction.d.ts +115 -0
- package/dist/components/interaction.js +416 -0
- package/dist/components/interaction.js.map +1 -0
- package/dist/components/jsx.cjs +3 -0
- package/dist/components/jsx.cjs.map +1 -0
- package/dist/components/jsx.d.cts +53 -0
- package/dist/components/jsx.d.ts +53 -0
- package/dist/components/jsx.js +2 -0
- package/dist/components/jsx.js.map +1 -0
- package/dist/components/layout.cjs +257 -0
- package/dist/components/layout.cjs.map +1 -0
- package/dist/components/layout.css +3 -0
- package/dist/components/layout.d.cts +99 -0
- package/dist/components/layout.d.ts +99 -0
- package/dist/components/layout.js +249 -0
- package/dist/components/layout.js.map +1 -0
- package/dist/components/lazy.cjs +92 -0
- package/dist/components/lazy.cjs.map +1 -0
- package/dist/components/lazy.d.cts +48 -0
- package/dist/components/lazy.d.ts +48 -0
- package/dist/components/lazy.js +87 -0
- package/dist/components/lazy.js.map +1 -0
- package/dist/components/lite.cjs +11095 -0
- package/dist/components/lite.cjs.map +1 -0
- package/dist/components/lite.d.cts +4 -0
- package/dist/components/lite.d.ts +4 -0
- package/dist/components/lite.js +10827 -0
- package/dist/components/lite.js.map +1 -0
- package/dist/components/packs.cjs +192 -0
- package/dist/components/packs.cjs.map +1 -0
- package/dist/components/packs.css +3 -0
- package/dist/components/packs.d.cts +72 -0
- package/dist/components/packs.d.ts +72 -0
- package/dist/components/packs.js +184 -0
- package/dist/components/packs.js.map +1 -0
- package/dist/components/page.cjs +824 -0
- package/dist/components/page.cjs.map +1 -0
- package/dist/components/page.css +11 -0
- package/dist/components/page.d.cts +249 -0
- package/dist/components/page.d.ts +249 -0
- package/dist/components/page.js +799 -0
- package/dist/components/page.js.map +1 -0
- package/dist/components/perf.cjs +120 -0
- package/dist/components/perf.cjs.map +1 -0
- package/dist/components/perf.d.cts +98 -0
- package/dist/components/perf.d.ts +98 -0
- package/dist/components/perf.js +110 -0
- package/dist/components/perf.js.map +1 -0
- package/dist/components/physics.cjs +448 -0
- package/dist/components/physics.cjs.map +1 -0
- package/dist/components/physics.css +5 -0
- package/dist/components/physics.d.cts +189 -0
- package/dist/components/physics.d.ts +189 -0
- package/dist/components/physics.js +430 -0
- package/dist/components/physics.js.map +1 -0
- package/dist/components/react.cjs +96 -0
- package/dist/components/react.cjs.map +1 -0
- package/dist/components/react.d.cts +18 -0
- package/dist/components/react.d.ts +18 -0
- package/dist/components/react.js +91 -0
- package/dist/components/react.js.map +1 -0
- package/dist/components/reveal.cjs +362 -0
- package/dist/components/reveal.cjs.map +1 -0
- package/dist/components/reveal.css +5 -0
- package/dist/components/reveal.d.cts +105 -0
- package/dist/components/reveal.d.ts +105 -0
- package/dist/components/reveal.js +353 -0
- package/dist/components/reveal.js.map +1 -0
- package/dist/components/solid.cjs +86 -0
- package/dist/components/solid.cjs.map +1 -0
- package/dist/components/solid.d.cts +1751 -0
- package/dist/components/solid.d.ts +1751 -0
- package/dist/components/solid.js +82 -0
- package/dist/components/solid.js.map +1 -0
- package/dist/components/svelte.cjs +68 -0
- package/dist/components/svelte.cjs.map +1 -0
- package/dist/components/svelte.d.cts +1733 -0
- package/dist/components/svelte.d.ts +1733 -0
- package/dist/components/svelte.js +64 -0
- package/dist/components/svelte.js.map +1 -0
- package/dist/components/svg.cjs +359 -0
- package/dist/components/svg.cjs.map +1 -0
- package/dist/components/svg.css +3 -0
- package/dist/components/svg.d.cts +113 -0
- package/dist/components/svg.d.ts +113 -0
- package/dist/components/svg.js +347 -0
- package/dist/components/svg.js.map +1 -0
- package/dist/components/text.cjs +968 -0
- package/dist/components/text.cjs.map +1 -0
- package/dist/components/text.css +8 -0
- package/dist/components/text.d.cts +342 -0
- package/dist/components/text.d.ts +342 -0
- package/dist/components/text.js +947 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/timeline.cjs +109 -0
- package/dist/components/timeline.cjs.map +1 -0
- package/dist/components/timeline.css +3 -0
- package/dist/components/timeline.d.cts +155 -0
- package/dist/components/timeline.d.ts +155 -0
- package/dist/components/timeline.js +103 -0
- package/dist/components/timeline.js.map +1 -0
- package/dist/components/tokens.cjs +226 -0
- package/dist/components/tokens.cjs.map +1 -0
- package/dist/components/tokens.d.cts +74 -0
- package/dist/components/tokens.d.ts +74 -0
- package/dist/components/tokens.js +211 -0
- package/dist/components/tokens.js.map +1 -0
- package/dist/components/transitions.cjs +430 -0
- package/dist/components/transitions.cjs.map +1 -0
- package/dist/components/transitions.css +5 -0
- package/dist/components/transitions.d.cts +126 -0
- package/dist/components/transitions.d.ts +126 -0
- package/dist/components/transitions.js +423 -0
- package/dist/components/transitions.js.map +1 -0
- package/dist/components/ui.cjs +1050 -0
- package/dist/components/ui.cjs.map +1 -0
- package/dist/components/ui.css +14 -0
- package/dist/components/ui.d.cts +224 -0
- package/dist/components/ui.d.ts +224 -0
- package/dist/components/ui.js +1034 -0
- package/dist/components/ui.js.map +1 -0
- package/dist/components/vue.cjs +67 -0
- package/dist/components/vue.cjs.map +1 -0
- package/dist/components/vue.d.cts +1722 -0
- package/dist/components/vue.d.ts +1722 -0
- package/dist/components/vue.js +64 -0
- package/dist/components/vue.js.map +1 -0
- package/dist/components/webgl.cjs +459 -0
- package/dist/components/webgl.cjs.map +1 -0
- package/dist/components/webgl.css +3 -0
- package/dist/components/webgl.d.cts +133 -0
- package/dist/components/webgl.d.ts +133 -0
- package/dist/components/webgl.js +442 -0
- package/dist/components/webgl.js.map +1 -0
- package/dist/components/widgets.cjs +591 -0
- package/dist/components/widgets.cjs.map +1 -0
- package/dist/components/widgets.d.cts +110 -0
- package/dist/components/widgets.d.ts +110 -0
- package/dist/components/widgets.js +581 -0
- package/dist/components/widgets.js.map +1 -0
- package/dist/components.cjs +351 -0
- package/dist/components.cjs.map +1 -0
- package/dist/components.css +75 -0
- package/dist/components.d.cts +2997 -0
- package/dist/components.d.ts +2997 -0
- package/dist/components.js +106 -0
- package/dist/components.js.map +1 -0
- package/dist/components.umd.js +23 -0
- package/dist/components.umd.js.map +1 -0
- package/dist/element.cjs +97 -0
- package/dist/element.cjs.map +1 -0
- package/dist/element.d.cts +215 -0
- package/dist/element.d.ts +215 -0
- package/dist/element.js +95 -0
- package/dist/element.js.map +1 -0
- package/dist/element.umd.js +2 -0
- package/dist/element.umd.js.map +1 -0
- package/dist/index.cjs +149 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +425 -0
- package/dist/index.d.ts +425 -0
- package/dist/index.js +131 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +15 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/presets/extended.cjs +243 -0
- package/dist/presets/extended.cjs.map +1 -0
- package/dist/presets/extended.d.cts +37 -0
- package/dist/presets/extended.d.ts +37 -0
- package/dist/presets/extended.js +239 -0
- package/dist/presets/extended.js.map +1 -0
- package/dist/presets-extended.umd.js +2 -0
- package/dist/presets-extended.umd.js.map +1 -0
- package/dist/react.cjs +68 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +158 -0
- package/dist/react.d.ts +158 -0
- package/dist/react.js +65 -0
- package/dist/react.js.map +1 -0
- package/dist/solid.cjs +93 -0
- package/dist/solid.cjs.map +1 -0
- package/dist/solid.d.cts +249 -0
- package/dist/solid.d.ts +249 -0
- package/dist/solid.js +89 -0
- package/dist/solid.js.map +1 -0
- package/dist/svelte.cjs +66 -0
- package/dist/svelte.cjs.map +1 -0
- package/dist/svelte.d.cts +243 -0
- package/dist/svelte.d.ts +243 -0
- package/dist/svelte.js +63 -0
- package/dist/svelte.js.map +1 -0
- package/dist/vue.cjs +62 -0
- package/dist/vue.cjs.map +1 -0
- package/dist/vue.d.cts +158 -0
- package/dist/vue.d.ts +158 -0
- package/dist/vue.js +60 -0
- package/dist/vue.js.map +1 -0
- package/dist/widgets.umd.js +2 -0
- package/dist/widgets.umd.js.map +1 -0
- package/docs/API.md +147 -0
- package/docs/ROADMAP.md +14 -0
- package/docs/accessibility.md +60 -0
- package/docs/components.md +564 -0
- package/docs/deprecations.md +30 -0
- package/docs/frameworks-ssr.md +100 -0
- package/docs/hybrid-apps.md +145 -0
- package/docs/images/showcase-detail.png +0 -0
- package/docs/images/showcase-grid.png +0 -0
- package/docs/images/showcase-mobile.png +0 -0
- package/docs/migration-from-aos.md +67 -0
- package/docs/migration-from-gsap-scrolltrigger.md +80 -0
- package/docs/motion-tokens.css +31 -0
- package/docs/motion-tokens.md +46 -0
- package/docs/motion.tokens.json +132 -0
- package/docs/performance.md +24 -0
- package/docs/presets.md +310 -0
- package/docs/upgrading-3.md +21 -0
- package/docs/upgrading-4.md +65 -0
- package/docs/upgrading-5.md +31 -0
- package/docs/upgrading-6.md +32 -0
- package/docs/windows-apps.md +119 -0
- package/package.json +562 -4
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Members shared by every `<usa-*>` element. Attribute helpers, a cleanup
|
|
3
|
+
* bag that is emptied on disconnect, and motion helpers that degrade to the
|
|
4
|
+
* final state without WAAPI or under reduced motion.
|
|
5
|
+
*/
|
|
6
|
+
interface UsaElement extends HTMLElement {
|
|
7
|
+
/** `true` while reduced motion applies to this element. */
|
|
8
|
+
readonly reduced: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare const SPRING_EFFECTS: readonly ["bounce-in", "pop", "drop", "jelly", "rubber-band"];
|
|
12
|
+
type SpringEffect = (typeof SPRING_EFFECTS)[number];
|
|
13
|
+
/** Keyframes of a spring effect (entrances use spring timing, attention effects fixed frames). */
|
|
14
|
+
declare function springEffectKeyframes(effect: string, reduced?: boolean): Keyframe[];
|
|
15
|
+
/**
|
|
16
|
+
* `<usa-spring>` — spring / bounce effects on its content.
|
|
17
|
+
*
|
|
18
|
+
* Attributes: `effect` (`bounce-in` default, `pop`, `drop`, `jelly`,
|
|
19
|
+
* `rubber-band`), `trigger` (`view` default, `hover`, `click`, `manual`),
|
|
20
|
+
* `preset` (`gentle`, `wobbly`, `stiff`, `bouncy`, …) or `stiffness` /
|
|
21
|
+
* `damping` / `mass`, `delay` (ms), `duration` (ms, attention effects; 900),
|
|
22
|
+
* `repeat` (replay every time it re-enters the view), `block`.
|
|
23
|
+
* Events: `usa:complete`. Reduced motion: entrances fade, attention effects do nothing.
|
|
24
|
+
*/
|
|
25
|
+
interface UsaSpringElement extends UsaElement {
|
|
26
|
+
effect: string;
|
|
27
|
+
play(): Promise<void>;
|
|
28
|
+
reset(): void;
|
|
29
|
+
}
|
|
30
|
+
declare function defineSpring(tag?: string): CustomElementConstructor | undefined;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* `<usa-draggable>` — drag its content with the pointer (mouse, touch, pen)
|
|
34
|
+
* or the arrow keys; physics on release.
|
|
35
|
+
*
|
|
36
|
+
* Attributes: `axis` (`both` default, `x`, `y`), `spring-back` (return to
|
|
37
|
+
* the origin with a spring), `inertia` (keep gliding after a flick),
|
|
38
|
+
* `snap` (grid size like `80`, or points like `0,120,240`), `bounds`
|
|
39
|
+
* (`parent` = stay inside the parent box, rubber-banding past its edges),
|
|
40
|
+
* `preset` (spring, default `wobbly`), `step` (arrow-key step, px, 16),
|
|
41
|
+
* `disabled`. Methods: `moveTo(x, y, animate?)`, `reset()`. Events:
|
|
42
|
+
* `usa:drag-start`, `usa:drag-end` (`{ x, y, vx, vy }`), `usa:settle`.
|
|
43
|
+
* Reduced motion: positions change instantly (no spring or inertia).
|
|
44
|
+
*/
|
|
45
|
+
interface UsaDraggableElement extends UsaElement {
|
|
46
|
+
readonly x: number;
|
|
47
|
+
readonly y: number;
|
|
48
|
+
readonly dragging: boolean;
|
|
49
|
+
moveTo(x: number, y: number, animate?: boolean): void;
|
|
50
|
+
reset(): void;
|
|
51
|
+
}
|
|
52
|
+
declare function defineDraggable(tag?: string): CustomElementConstructor | undefined;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* `<usa-overscroll>` — an elastic scroll container: pulling past the top or
|
|
56
|
+
* bottom (touch, trackpad or wheel) stretches the content with iOS-style
|
|
57
|
+
* rubber-band resistance and it springs back on release.
|
|
58
|
+
*
|
|
59
|
+
* Attributes: `axis` (`y` default, `x`), `max` (largest stretch in px, 120),
|
|
60
|
+
* `preset` (spring, default `default`), `disabled`. CSS variable
|
|
61
|
+
* `--usa-overscroll` holds the current offset. Reduced motion: no stretch
|
|
62
|
+
* (a plain scroll container with `overscroll-behavior: contain`).
|
|
63
|
+
*/
|
|
64
|
+
interface UsaOverscrollElement extends UsaElement {
|
|
65
|
+
/** Current stretch in px (negative = pulled past the end). */
|
|
66
|
+
readonly offset: number;
|
|
67
|
+
}
|
|
68
|
+
declare function defineOverscroll(tag?: string): CustomElementConstructor | undefined;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Spring physics core (v2.3). A damped harmonic oscillator integrated in
|
|
72
|
+
* 1 ms steps: `stiffness` (k, N/m), `damping` (c) and `mass` (m). Used by
|
|
73
|
+
* the `<usa-spring>`, `<usa-draggable>` and `<usa-overscroll>` elements and
|
|
74
|
+
* exported for your own animations:
|
|
75
|
+
*
|
|
76
|
+
* - `springEasing()` turns a spring into a CSS `linear()` easing + duration
|
|
77
|
+
* for WAAPI / CSS (falls back to a cubic-bezier overshoot where `linear()`
|
|
78
|
+
* is unsupported);
|
|
79
|
+
* - `spring(el, keyframes, cfg)` animates with it;
|
|
80
|
+
* - `createSpring()` is an interruptible, velocity-preserving value for
|
|
81
|
+
* gestures (drag, inertia, snap).
|
|
82
|
+
*/
|
|
83
|
+
interface SpringConfig {
|
|
84
|
+
/** Spring stiffness (default 170). Higher = faster, snappier. */
|
|
85
|
+
stiffness?: number;
|
|
86
|
+
/** Damping / friction (default 26). Lower = more bounces. */
|
|
87
|
+
damping?: number;
|
|
88
|
+
/** Mass (default 1). Higher = slower, heavier. */
|
|
89
|
+
mass?: number;
|
|
90
|
+
/** Initial velocity in progress units per second (default 0). */
|
|
91
|
+
velocity?: number;
|
|
92
|
+
/** Rest threshold (default 0.001). */
|
|
93
|
+
precision?: number;
|
|
94
|
+
}
|
|
95
|
+
type SpringPreset = 'default' | 'gentle' | 'wobbly' | 'stiff' | 'bouncy' | 'slow' | 'molasses';
|
|
96
|
+
declare const SPRING_PRESETS: Record<SpringPreset, Required<Pick<SpringConfig, 'stiffness' | 'damping' | 'mass'>>>;
|
|
97
|
+
type SpringInput = SpringPreset | SpringConfig | string | undefined;
|
|
98
|
+
/** Resolve a preset name or a partial config to a full config. */
|
|
99
|
+
declare function resolveSpring(input?: SpringInput): Required<SpringConfig>;
|
|
100
|
+
/** One integration step (semi-implicit Euler) towards `to`. Returns [x, v]. */
|
|
101
|
+
declare function stepSpring(cfg: Required<SpringConfig>, x: number, v: number, to: number, dt: number): [number, number];
|
|
102
|
+
/**
|
|
103
|
+
* Sample the spring from 0 to 1 at `fps` (default 60). `values` may exceed 1
|
|
104
|
+
* (overshoot); `duration` is the time to rest, in ms (max 10 s).
|
|
105
|
+
*/
|
|
106
|
+
declare function springSamples(input?: SpringInput, fps?: number): {
|
|
107
|
+
values: number[];
|
|
108
|
+
duration: number;
|
|
109
|
+
};
|
|
110
|
+
/** `true` when CSS `linear()` easing is supported. */
|
|
111
|
+
declare function supportsLinearEasing(): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* The spring as `{ easing, duration }` for `el.animate()` / CSS. `easing` is
|
|
114
|
+
* a `linear(…)` function with at most `points` stops (default 48), or a
|
|
115
|
+
* cubic-bezier overshoot where `linear()` is unsupported.
|
|
116
|
+
*/
|
|
117
|
+
declare function springEasing(input?: SpringInput, points?: number): {
|
|
118
|
+
easing: string;
|
|
119
|
+
duration: number;
|
|
120
|
+
};
|
|
121
|
+
/** Build a CSS `linear()` easing from samples (down-sampled to `points`). */
|
|
122
|
+
declare function linearEasing(values: number[], points?: number): string;
|
|
123
|
+
/**
|
|
124
|
+
* Animate `el` between keyframes with spring timing (WAAPI). Under reduced
|
|
125
|
+
* motion the final frame is applied immediately. Returns the Animation (or
|
|
126
|
+
* `null` without WAAPI / under reduced motion).
|
|
127
|
+
*/
|
|
128
|
+
declare function spring(el: Element, keyframes: Keyframe[], input?: SpringInput, options?: KeyframeAnimationOptions): Animation | null;
|
|
129
|
+
interface SpringValueOptions {
|
|
130
|
+
/** Start value (default 0). */
|
|
131
|
+
value?: number;
|
|
132
|
+
/** Spring config or preset (default `'default'`). */
|
|
133
|
+
spring?: SpringInput;
|
|
134
|
+
/** Called with the value every frame (and on `jump()`). */
|
|
135
|
+
onUpdate?: (value: number, velocity: number) => void;
|
|
136
|
+
/** Called when the value comes to rest at its target. */
|
|
137
|
+
onRest?: (value: number) => void;
|
|
138
|
+
}
|
|
139
|
+
interface SpringValue {
|
|
140
|
+
readonly value: number;
|
|
141
|
+
/** Units per second. */
|
|
142
|
+
readonly velocity: number;
|
|
143
|
+
readonly target: number;
|
|
144
|
+
readonly animating: boolean;
|
|
145
|
+
/** Animate to `target`, optionally with a new initial velocity (units/s). */
|
|
146
|
+
set(target: number, velocity?: number): void;
|
|
147
|
+
/** Jump to `value` with no animation. */
|
|
148
|
+
jump(value: number): void;
|
|
149
|
+
/** Stop where it is. */
|
|
150
|
+
stop(): void;
|
|
151
|
+
/** Change the spring config. */
|
|
152
|
+
configure(spring: SpringInput): void;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* An interruptible spring-animated number: call `set()` as often as you like,
|
|
156
|
+
* the motion keeps its velocity (like iOS / Framer springs). Reduced motion
|
|
157
|
+
* jumps straight to the target.
|
|
158
|
+
*/
|
|
159
|
+
declare function createSpring(opts?: SpringValueOptions): SpringValue;
|
|
160
|
+
/**
|
|
161
|
+
* Where a flick at `velocity` (units/s) comes to rest with exponential
|
|
162
|
+
* decay: `value + velocity · timeConstant` (default 0.325 s, iOS-like).
|
|
163
|
+
*/
|
|
164
|
+
declare function projectInertia(value: number, velocity: number, timeConstant?: number): number;
|
|
165
|
+
/** Snap to a grid (`number`) or the nearest of a list of points. */
|
|
166
|
+
declare function snapTo(value: number, to: number | number[] | null | undefined): number;
|
|
167
|
+
/** iOS-style rubber-band resistance: how far content moves when pulled `distance` past an edge. */
|
|
168
|
+
declare function rubberBand(distance: number, dimension: number, constant?: number): number;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* motionary/components/physics — spring & bounce physics (v2.3).
|
|
172
|
+
* `<usa-spring>` (bounce-in, pop, drop, jelly, rubber-band), `<usa-draggable>`
|
|
173
|
+
* (spring-back, inertia, snap) and `<usa-overscroll>` (elastic edges), plus
|
|
174
|
+
* the spring core: `spring()`, `springEasing()`, `createSpring()`,
|
|
175
|
+
* `SPRING_PRESETS`, `projectInertia()`, `snapTo()`, `rubberBand()`.
|
|
176
|
+
*/
|
|
177
|
+
|
|
178
|
+
/** Register every component of this category under its default tag. */
|
|
179
|
+
declare function definePhysicsComponents(): void;
|
|
180
|
+
declare global {
|
|
181
|
+
interface HTMLElementTagNameMap {
|
|
182
|
+
'usa-spring': UsaSpringElement;
|
|
183
|
+
'usa-draggable': UsaDraggableElement;
|
|
184
|
+
'usa-overscroll': UsaOverscrollElement;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export { SPRING_EFFECTS, SPRING_PRESETS, createSpring, defineDraggable, defineOverscroll, definePhysicsComponents, defineSpring, linearEasing, projectInertia, resolveSpring, rubberBand, snapTo, spring, springEasing, springEffectKeyframes, springSamples, stepSpring, supportsLinearEasing };
|
|
189
|
+
export type { SpringConfig, SpringEffect, SpringInput, SpringPreset, SpringValue, SpringValueOptions, UsaDraggableElement, UsaOverscrollElement, UsaSpringElement };
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Members shared by every `<usa-*>` element. Attribute helpers, a cleanup
|
|
3
|
+
* bag that is emptied on disconnect, and motion helpers that degrade to the
|
|
4
|
+
* final state without WAAPI or under reduced motion.
|
|
5
|
+
*/
|
|
6
|
+
interface UsaElement extends HTMLElement {
|
|
7
|
+
/** `true` while reduced motion applies to this element. */
|
|
8
|
+
readonly reduced: boolean;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
declare const SPRING_EFFECTS: readonly ["bounce-in", "pop", "drop", "jelly", "rubber-band"];
|
|
12
|
+
type SpringEffect = (typeof SPRING_EFFECTS)[number];
|
|
13
|
+
/** Keyframes of a spring effect (entrances use spring timing, attention effects fixed frames). */
|
|
14
|
+
declare function springEffectKeyframes(effect: string, reduced?: boolean): Keyframe[];
|
|
15
|
+
/**
|
|
16
|
+
* `<usa-spring>` — spring / bounce effects on its content.
|
|
17
|
+
*
|
|
18
|
+
* Attributes: `effect` (`bounce-in` default, `pop`, `drop`, `jelly`,
|
|
19
|
+
* `rubber-band`), `trigger` (`view` default, `hover`, `click`, `manual`),
|
|
20
|
+
* `preset` (`gentle`, `wobbly`, `stiff`, `bouncy`, …) or `stiffness` /
|
|
21
|
+
* `damping` / `mass`, `delay` (ms), `duration` (ms, attention effects; 900),
|
|
22
|
+
* `repeat` (replay every time it re-enters the view), `block`.
|
|
23
|
+
* Events: `usa:complete`. Reduced motion: entrances fade, attention effects do nothing.
|
|
24
|
+
*/
|
|
25
|
+
interface UsaSpringElement extends UsaElement {
|
|
26
|
+
effect: string;
|
|
27
|
+
play(): Promise<void>;
|
|
28
|
+
reset(): void;
|
|
29
|
+
}
|
|
30
|
+
declare function defineSpring(tag?: string): CustomElementConstructor | undefined;
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* `<usa-draggable>` — drag its content with the pointer (mouse, touch, pen)
|
|
34
|
+
* or the arrow keys; physics on release.
|
|
35
|
+
*
|
|
36
|
+
* Attributes: `axis` (`both` default, `x`, `y`), `spring-back` (return to
|
|
37
|
+
* the origin with a spring), `inertia` (keep gliding after a flick),
|
|
38
|
+
* `snap` (grid size like `80`, or points like `0,120,240`), `bounds`
|
|
39
|
+
* (`parent` = stay inside the parent box, rubber-banding past its edges),
|
|
40
|
+
* `preset` (spring, default `wobbly`), `step` (arrow-key step, px, 16),
|
|
41
|
+
* `disabled`. Methods: `moveTo(x, y, animate?)`, `reset()`. Events:
|
|
42
|
+
* `usa:drag-start`, `usa:drag-end` (`{ x, y, vx, vy }`), `usa:settle`.
|
|
43
|
+
* Reduced motion: positions change instantly (no spring or inertia).
|
|
44
|
+
*/
|
|
45
|
+
interface UsaDraggableElement extends UsaElement {
|
|
46
|
+
readonly x: number;
|
|
47
|
+
readonly y: number;
|
|
48
|
+
readonly dragging: boolean;
|
|
49
|
+
moveTo(x: number, y: number, animate?: boolean): void;
|
|
50
|
+
reset(): void;
|
|
51
|
+
}
|
|
52
|
+
declare function defineDraggable(tag?: string): CustomElementConstructor | undefined;
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* `<usa-overscroll>` — an elastic scroll container: pulling past the top or
|
|
56
|
+
* bottom (touch, trackpad or wheel) stretches the content with iOS-style
|
|
57
|
+
* rubber-band resistance and it springs back on release.
|
|
58
|
+
*
|
|
59
|
+
* Attributes: `axis` (`y` default, `x`), `max` (largest stretch in px, 120),
|
|
60
|
+
* `preset` (spring, default `default`), `disabled`. CSS variable
|
|
61
|
+
* `--usa-overscroll` holds the current offset. Reduced motion: no stretch
|
|
62
|
+
* (a plain scroll container with `overscroll-behavior: contain`).
|
|
63
|
+
*/
|
|
64
|
+
interface UsaOverscrollElement extends UsaElement {
|
|
65
|
+
/** Current stretch in px (negative = pulled past the end). */
|
|
66
|
+
readonly offset: number;
|
|
67
|
+
}
|
|
68
|
+
declare function defineOverscroll(tag?: string): CustomElementConstructor | undefined;
|
|
69
|
+
|
|
70
|
+
/**
|
|
71
|
+
* Spring physics core (v2.3). A damped harmonic oscillator integrated in
|
|
72
|
+
* 1 ms steps: `stiffness` (k, N/m), `damping` (c) and `mass` (m). Used by
|
|
73
|
+
* the `<usa-spring>`, `<usa-draggable>` and `<usa-overscroll>` elements and
|
|
74
|
+
* exported for your own animations:
|
|
75
|
+
*
|
|
76
|
+
* - `springEasing()` turns a spring into a CSS `linear()` easing + duration
|
|
77
|
+
* for WAAPI / CSS (falls back to a cubic-bezier overshoot where `linear()`
|
|
78
|
+
* is unsupported);
|
|
79
|
+
* - `spring(el, keyframes, cfg)` animates with it;
|
|
80
|
+
* - `createSpring()` is an interruptible, velocity-preserving value for
|
|
81
|
+
* gestures (drag, inertia, snap).
|
|
82
|
+
*/
|
|
83
|
+
interface SpringConfig {
|
|
84
|
+
/** Spring stiffness (default 170). Higher = faster, snappier. */
|
|
85
|
+
stiffness?: number;
|
|
86
|
+
/** Damping / friction (default 26). Lower = more bounces. */
|
|
87
|
+
damping?: number;
|
|
88
|
+
/** Mass (default 1). Higher = slower, heavier. */
|
|
89
|
+
mass?: number;
|
|
90
|
+
/** Initial velocity in progress units per second (default 0). */
|
|
91
|
+
velocity?: number;
|
|
92
|
+
/** Rest threshold (default 0.001). */
|
|
93
|
+
precision?: number;
|
|
94
|
+
}
|
|
95
|
+
type SpringPreset = 'default' | 'gentle' | 'wobbly' | 'stiff' | 'bouncy' | 'slow' | 'molasses';
|
|
96
|
+
declare const SPRING_PRESETS: Record<SpringPreset, Required<Pick<SpringConfig, 'stiffness' | 'damping' | 'mass'>>>;
|
|
97
|
+
type SpringInput = SpringPreset | SpringConfig | string | undefined;
|
|
98
|
+
/** Resolve a preset name or a partial config to a full config. */
|
|
99
|
+
declare function resolveSpring(input?: SpringInput): Required<SpringConfig>;
|
|
100
|
+
/** One integration step (semi-implicit Euler) towards `to`. Returns [x, v]. */
|
|
101
|
+
declare function stepSpring(cfg: Required<SpringConfig>, x: number, v: number, to: number, dt: number): [number, number];
|
|
102
|
+
/**
|
|
103
|
+
* Sample the spring from 0 to 1 at `fps` (default 60). `values` may exceed 1
|
|
104
|
+
* (overshoot); `duration` is the time to rest, in ms (max 10 s).
|
|
105
|
+
*/
|
|
106
|
+
declare function springSamples(input?: SpringInput, fps?: number): {
|
|
107
|
+
values: number[];
|
|
108
|
+
duration: number;
|
|
109
|
+
};
|
|
110
|
+
/** `true` when CSS `linear()` easing is supported. */
|
|
111
|
+
declare function supportsLinearEasing(): boolean;
|
|
112
|
+
/**
|
|
113
|
+
* The spring as `{ easing, duration }` for `el.animate()` / CSS. `easing` is
|
|
114
|
+
* a `linear(…)` function with at most `points` stops (default 48), or a
|
|
115
|
+
* cubic-bezier overshoot where `linear()` is unsupported.
|
|
116
|
+
*/
|
|
117
|
+
declare function springEasing(input?: SpringInput, points?: number): {
|
|
118
|
+
easing: string;
|
|
119
|
+
duration: number;
|
|
120
|
+
};
|
|
121
|
+
/** Build a CSS `linear()` easing from samples (down-sampled to `points`). */
|
|
122
|
+
declare function linearEasing(values: number[], points?: number): string;
|
|
123
|
+
/**
|
|
124
|
+
* Animate `el` between keyframes with spring timing (WAAPI). Under reduced
|
|
125
|
+
* motion the final frame is applied immediately. Returns the Animation (or
|
|
126
|
+
* `null` without WAAPI / under reduced motion).
|
|
127
|
+
*/
|
|
128
|
+
declare function spring(el: Element, keyframes: Keyframe[], input?: SpringInput, options?: KeyframeAnimationOptions): Animation | null;
|
|
129
|
+
interface SpringValueOptions {
|
|
130
|
+
/** Start value (default 0). */
|
|
131
|
+
value?: number;
|
|
132
|
+
/** Spring config or preset (default `'default'`). */
|
|
133
|
+
spring?: SpringInput;
|
|
134
|
+
/** Called with the value every frame (and on `jump()`). */
|
|
135
|
+
onUpdate?: (value: number, velocity: number) => void;
|
|
136
|
+
/** Called when the value comes to rest at its target. */
|
|
137
|
+
onRest?: (value: number) => void;
|
|
138
|
+
}
|
|
139
|
+
interface SpringValue {
|
|
140
|
+
readonly value: number;
|
|
141
|
+
/** Units per second. */
|
|
142
|
+
readonly velocity: number;
|
|
143
|
+
readonly target: number;
|
|
144
|
+
readonly animating: boolean;
|
|
145
|
+
/** Animate to `target`, optionally with a new initial velocity (units/s). */
|
|
146
|
+
set(target: number, velocity?: number): void;
|
|
147
|
+
/** Jump to `value` with no animation. */
|
|
148
|
+
jump(value: number): void;
|
|
149
|
+
/** Stop where it is. */
|
|
150
|
+
stop(): void;
|
|
151
|
+
/** Change the spring config. */
|
|
152
|
+
configure(spring: SpringInput): void;
|
|
153
|
+
}
|
|
154
|
+
/**
|
|
155
|
+
* An interruptible spring-animated number: call `set()` as often as you like,
|
|
156
|
+
* the motion keeps its velocity (like iOS / Framer springs). Reduced motion
|
|
157
|
+
* jumps straight to the target.
|
|
158
|
+
*/
|
|
159
|
+
declare function createSpring(opts?: SpringValueOptions): SpringValue;
|
|
160
|
+
/**
|
|
161
|
+
* Where a flick at `velocity` (units/s) comes to rest with exponential
|
|
162
|
+
* decay: `value + velocity · timeConstant` (default 0.325 s, iOS-like).
|
|
163
|
+
*/
|
|
164
|
+
declare function projectInertia(value: number, velocity: number, timeConstant?: number): number;
|
|
165
|
+
/** Snap to a grid (`number`) or the nearest of a list of points. */
|
|
166
|
+
declare function snapTo(value: number, to: number | number[] | null | undefined): number;
|
|
167
|
+
/** iOS-style rubber-band resistance: how far content moves when pulled `distance` past an edge. */
|
|
168
|
+
declare function rubberBand(distance: number, dimension: number, constant?: number): number;
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* motionary/components/physics — spring & bounce physics (v2.3).
|
|
172
|
+
* `<usa-spring>` (bounce-in, pop, drop, jelly, rubber-band), `<usa-draggable>`
|
|
173
|
+
* (spring-back, inertia, snap) and `<usa-overscroll>` (elastic edges), plus
|
|
174
|
+
* the spring core: `spring()`, `springEasing()`, `createSpring()`,
|
|
175
|
+
* `SPRING_PRESETS`, `projectInertia()`, `snapTo()`, `rubberBand()`.
|
|
176
|
+
*/
|
|
177
|
+
|
|
178
|
+
/** Register every component of this category under its default tag. */
|
|
179
|
+
declare function definePhysicsComponents(): void;
|
|
180
|
+
declare global {
|
|
181
|
+
interface HTMLElementTagNameMap {
|
|
182
|
+
'usa-spring': UsaSpringElement;
|
|
183
|
+
'usa-draggable': UsaDraggableElement;
|
|
184
|
+
'usa-overscroll': UsaOverscrollElement;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
|
|
188
|
+
export { SPRING_EFFECTS, SPRING_PRESETS, createSpring, defineDraggable, defineOverscroll, definePhysicsComponents, defineSpring, linearEasing, projectInertia, resolveSpring, rubberBand, snapTo, spring, springEasing, springEffectKeyframes, springSamples, stepSpring, supportsLinearEasing };
|
|
189
|
+
export type { SpringConfig, SpringEffect, SpringInput, SpringPreset, SpringValue, SpringValueOptions, UsaDraggableElement, UsaOverscrollElement, UsaSpringElement };
|