use-scroll-animate 6.1.0 → 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.
- package/CHANGELOG.md +11 -0
- package/README.md +157 -411
- package/README_ja.md +170 -175
- package/README_zh.md +169 -198
- package/dist/chunks/{base-B5i8qQPR.cjs → base-BaQV-2ha.cjs} +3 -3
- package/dist/chunks/base-BaQV-2ha.cjs.map +1 -0
- package/dist/chunks/{base-C3Sw9sAO.js → base-Yno7N2eC.js} +3 -3
- package/dist/chunks/base-Yno7N2eC.js.map +1 -0
- package/dist/chunks/{core-BYLtO0Po.cjs → core-B5T0dhFH.cjs} +3 -3
- package/dist/chunks/core-B5T0dhFH.cjs.map +1 -0
- package/dist/chunks/{core-BDcszY4L.cjs → core-BGAyaY6L.cjs} +2 -2
- package/dist/chunks/{core-BDcszY4L.cjs.map → core-BGAyaY6L.cjs.map} +1 -1
- package/dist/chunks/{core-BTf__I-8.js → core-BIOaYdgN.js} +2 -2
- package/dist/chunks/{core-BTf__I-8.js.map → core-BIOaYdgN.js.map} +1 -1
- package/dist/chunks/{core-DN3hHbHh.js → core-CUGCsMsJ.js} +2 -2
- package/dist/chunks/{core-DN3hHbHh.js.map → core-CUGCsMsJ.js.map} +1 -1
- package/dist/chunks/{core-BVQW34aX.js → core-D7cVumUu.js} +3 -3
- package/dist/chunks/core-D7cVumUu.js.map +1 -0
- package/dist/chunks/{core-BjOYKSrV.cjs → core-zq17EeCI.cjs} +2 -2
- package/dist/chunks/{core-BjOYKSrV.cjs.map → core-zq17EeCI.cjs.map} +1 -1
- package/dist/chunks/{fx-ChjxrMBo.js → fx-BqDeFywO.js} +2 -2
- package/dist/chunks/{fx-ChjxrMBo.js.map → fx-BqDeFywO.js.map} +1 -1
- package/dist/chunks/{fx-B8hk1Fby.cjs → fx-lBGVtQO1.cjs} +2 -2
- package/dist/chunks/{fx-B8hk1Fby.cjs.map → fx-lBGVtQO1.cjs.map} +1 -1
- package/dist/chunks/{presets-BJ09NeTo.js → presets-BYBVJVeP.js} +3 -3
- package/dist/chunks/presets-BYBVJVeP.js.map +1 -0
- package/dist/chunks/{presets-D2ksQNzJ.cjs → presets-CUHys3sK.cjs} +3 -3
- package/dist/chunks/presets-CUHys3sK.cjs.map +1 -0
- package/dist/chunks/{spring-CckMe3x0.js → spring-DfQO5USi.js} +2 -2
- package/dist/chunks/{spring-CckMe3x0.js.map → spring-DfQO5USi.js.map} +1 -1
- package/dist/chunks/{spring--oZh55tB.cjs → spring-Dgx187Vh.cjs} +2 -2
- package/dist/chunks/{spring--oZh55tB.cjs.map → spring-Dgx187Vh.cjs.map} +1 -1
- package/dist/chunks/{stagger-CvhYlKrF.cjs → stagger-CCFyhzSw.cjs} +3 -3
- package/dist/chunks/stagger-CCFyhzSw.cjs.map +1 -0
- package/dist/chunks/{stagger-Dh4V-OL0.js → stagger-DtMKo2SK.js} +3 -3
- package/dist/chunks/stagger-DtMKo2SK.js.map +1 -0
- package/dist/chunks/{variants-DxPmgrNX.cjs → variants-BhjyddG8.cjs} +2 -2
- package/dist/chunks/{variants-DxPmgrNX.cjs.map → variants-BhjyddG8.cjs.map} +1 -1
- package/dist/chunks/{variants-Bsevy6Xm.js → variants-VNscPeTD.js} +2 -2
- package/dist/chunks/{variants-Bsevy6Xm.js.map → variants-VNscPeTD.js.map} +1 -1
- package/dist/components/a11y.cjs +4 -4
- package/dist/components/a11y.cjs.map +1 -1
- package/dist/components/a11y.d.cts +2 -2
- package/dist/components/a11y.d.ts +2 -2
- package/dist/components/a11y.js +5 -5
- package/dist/components/a11y.js.map +1 -1
- package/dist/components/angular.cjs +8 -8
- package/dist/components/angular.cjs.map +1 -1
- package/dist/components/angular.d.cts +22 -22
- package/dist/components/angular.d.ts +22 -22
- package/dist/components/angular.js +8 -8
- package/dist/components/angular.js.map +1 -1
- package/dist/components/background.cjs +3 -3
- package/dist/components/background.cjs.map +1 -1
- package/dist/components/background.css +1 -1
- package/dist/components/background.d.cts +1 -1
- package/dist/components/background.d.ts +1 -1
- package/dist/components/background.js +3 -3
- package/dist/components/background.js.map +1 -1
- package/dist/components/bridge.cjs +2 -2
- package/dist/components/bridge.cjs.map +1 -1
- package/dist/components/bridge.d.cts +1 -1
- package/dist/components/bridge.d.ts +1 -1
- package/dist/components/bridge.js +2 -2
- package/dist/components/bridge.js.map +1 -1
- package/dist/components/cards.cjs +3 -3
- package/dist/components/cards.cjs.map +1 -1
- package/dist/components/cards.css +1 -1
- package/dist/components/cards.d.cts +1 -1
- package/dist/components/cards.d.ts +1 -1
- package/dist/components/cards.js +3 -3
- package/dist/components/cards.js.map +1 -1
- package/dist/components/click.cjs +4 -4
- package/dist/components/click.cjs.map +1 -1
- package/dist/components/click.css +1 -1
- package/dist/components/click.d.cts +1 -1
- package/dist/components/click.d.ts +1 -1
- package/dist/components/click.js +4 -4
- package/dist/components/click.js.map +1 -1
- package/dist/components/depth.cjs +4 -4
- package/dist/components/depth.cjs.map +1 -1
- package/dist/components/depth.css +1 -1
- package/dist/components/depth.d.cts +1 -1
- package/dist/components/depth.d.ts +1 -1
- package/dist/components/depth.js +4 -4
- package/dist/components/depth.js.map +1 -1
- package/dist/components/effects.cjs +13 -13
- package/dist/components/effects.cjs.map +1 -1
- package/dist/components/effects.d.cts +2 -2
- package/dist/components/effects.d.ts +2 -2
- package/dist/components/effects.js +13 -13
- package/dist/components/effects.js.map +1 -1
- package/dist/components/feedback.cjs +2 -2
- package/dist/components/feedback.cjs.map +1 -1
- package/dist/components/feedback.css +1 -1
- package/dist/components/feedback.d.cts +1 -1
- package/dist/components/feedback.d.ts +1 -1
- package/dist/components/feedback.js +2 -2
- package/dist/components/feedback.js.map +1 -1
- package/dist/components/fx.cjs +10 -10
- package/dist/components/fx.cjs.map +1 -1
- package/dist/components/fx.css +1 -1
- package/dist/components/fx.d.cts +2 -2
- package/dist/components/fx.d.ts +2 -2
- package/dist/components/fx.js +10 -10
- package/dist/components/fx.js.map +1 -1
- package/dist/components/gesture.cjs +4 -4
- package/dist/components/gesture.cjs.map +1 -1
- package/dist/components/gesture.css +1 -1
- package/dist/components/gesture.d.cts +1 -1
- package/dist/components/gesture.d.ts +1 -1
- package/dist/components/gesture.js +5 -5
- package/dist/components/gesture.js.map +1 -1
- package/dist/components/interaction.cjs +2 -2
- package/dist/components/interaction.cjs.map +1 -1
- package/dist/components/interaction.css +1 -1
- package/dist/components/interaction.d.cts +1 -1
- package/dist/components/interaction.d.ts +1 -1
- package/dist/components/interaction.js +2 -2
- package/dist/components/interaction.js.map +1 -1
- package/dist/components/jsx.d.cts +2 -2
- package/dist/components/jsx.d.ts +2 -2
- package/dist/components/layout.cjs +2 -2
- package/dist/components/layout.cjs.map +1 -1
- package/dist/components/layout.css +1 -1
- package/dist/components/layout.d.cts +1 -1
- package/dist/components/layout.d.ts +1 -1
- package/dist/components/layout.js +2 -2
- package/dist/components/layout.js.map +1 -1
- package/dist/components/lazy.cjs +2 -2
- package/dist/components/lazy.cjs.map +1 -1
- package/dist/components/lazy.d.cts +2 -2
- package/dist/components/lazy.d.ts +2 -2
- package/dist/components/lazy.js +2 -2
- package/dist/components/lazy.js.map +1 -1
- package/dist/components/lite.cjs +41 -41
- package/dist/components/lite.cjs.map +1 -1
- package/dist/components/lite.js +41 -41
- package/dist/components/lite.js.map +1 -1
- package/dist/components/packs.cjs +2 -2
- package/dist/components/packs.cjs.map +1 -1
- package/dist/components/packs.css +1 -1
- package/dist/components/packs.d.cts +1 -1
- package/dist/components/packs.d.ts +1 -1
- package/dist/components/packs.js +2 -2
- package/dist/components/packs.js.map +1 -1
- package/dist/components/page.cjs +3 -3
- package/dist/components/page.cjs.map +1 -1
- package/dist/components/page.css +1 -1
- package/dist/components/page.d.cts +1 -1
- package/dist/components/page.d.ts +1 -1
- package/dist/components/page.js +4 -4
- package/dist/components/page.js.map +1 -1
- package/dist/components/perf.cjs +3 -3
- package/dist/components/perf.cjs.map +1 -1
- package/dist/components/perf.d.cts +2 -2
- package/dist/components/perf.d.ts +2 -2
- package/dist/components/perf.js +4 -4
- package/dist/components/perf.js.map +1 -1
- package/dist/components/physics.cjs +3 -3
- package/dist/components/physics.cjs.map +1 -1
- package/dist/components/physics.css +1 -1
- package/dist/components/physics.d.cts +1 -1
- package/dist/components/physics.d.ts +1 -1
- package/dist/components/physics.js +4 -4
- package/dist/components/physics.js.map +1 -1
- package/dist/components/react.cjs +4 -4
- package/dist/components/react.cjs.map +1 -1
- package/dist/components/react.js +4 -4
- package/dist/components/react.js.map +1 -1
- package/dist/components/reveal.cjs +2 -2
- package/dist/components/reveal.cjs.map +1 -1
- package/dist/components/reveal.css +1 -1
- package/dist/components/reveal.d.cts +1 -1
- package/dist/components/reveal.d.ts +1 -1
- package/dist/components/reveal.js +2 -2
- package/dist/components/reveal.js.map +1 -1
- package/dist/components/solid.cjs +9 -9
- package/dist/components/solid.cjs.map +1 -1
- package/dist/components/solid.d.cts +22 -22
- package/dist/components/solid.d.ts +22 -22
- package/dist/components/solid.js +9 -9
- package/dist/components/solid.js.map +1 -1
- package/dist/components/svelte.cjs +8 -8
- package/dist/components/svelte.cjs.map +1 -1
- package/dist/components/svelte.d.cts +22 -22
- package/dist/components/svelte.d.ts +22 -22
- package/dist/components/svelte.js +8 -8
- package/dist/components/svelte.js.map +1 -1
- package/dist/components/svg.cjs +2 -2
- package/dist/components/svg.cjs.map +1 -1
- package/dist/components/svg.css +1 -1
- package/dist/components/svg.d.cts +1 -1
- package/dist/components/svg.d.ts +1 -1
- package/dist/components/svg.js +2 -2
- package/dist/components/svg.js.map +1 -1
- package/dist/components/text.cjs +3 -3
- package/dist/components/text.cjs.map +1 -1
- package/dist/components/text.css +1 -1
- package/dist/components/text.d.cts +1 -1
- package/dist/components/text.d.ts +1 -1
- package/dist/components/text.js +3 -3
- package/dist/components/text.js.map +1 -1
- package/dist/components/timeline.cjs +3 -3
- package/dist/components/timeline.cjs.map +1 -1
- package/dist/components/timeline.css +1 -1
- package/dist/components/timeline.d.cts +1 -1
- package/dist/components/timeline.d.ts +1 -1
- package/dist/components/timeline.js +4 -4
- package/dist/components/timeline.js.map +1 -1
- package/dist/components/tokens.cjs +2 -2
- package/dist/components/tokens.cjs.map +1 -1
- package/dist/components/tokens.d.cts +2 -2
- package/dist/components/tokens.d.ts +2 -2
- package/dist/components/tokens.js +2 -2
- package/dist/components/tokens.js.map +1 -1
- package/dist/components/transitions.cjs +2 -2
- package/dist/components/transitions.cjs.map +1 -1
- package/dist/components/transitions.css +1 -1
- package/dist/components/transitions.d.cts +1 -1
- package/dist/components/transitions.d.ts +1 -1
- package/dist/components/transitions.js +2 -2
- package/dist/components/transitions.js.map +1 -1
- package/dist/components/ui.cjs +4 -4
- package/dist/components/ui.cjs.map +1 -1
- package/dist/components/ui.css +1 -1
- package/dist/components/ui.d.cts +1 -1
- package/dist/components/ui.d.ts +1 -1
- package/dist/components/ui.js +5 -5
- package/dist/components/ui.js.map +1 -1
- package/dist/components/vue.cjs +9 -9
- package/dist/components/vue.cjs.map +1 -1
- package/dist/components/vue.d.cts +23 -23
- package/dist/components/vue.d.ts +23 -23
- package/dist/components/vue.js +9 -9
- package/dist/components/vue.js.map +1 -1
- package/dist/components/webgl.cjs +2 -2
- package/dist/components/webgl.cjs.map +1 -1
- package/dist/components/webgl.css +1 -1
- package/dist/components/webgl.d.cts +1 -1
- package/dist/components/webgl.d.ts +1 -1
- package/dist/components/webgl.js +2 -2
- package/dist/components/webgl.js.map +1 -1
- package/dist/components.cjs +9 -9
- package/dist/components.cjs.map +1 -1
- package/dist/components.css +1 -1
- package/dist/components.d.cts +30 -30
- package/dist/components.d.ts +30 -30
- package/dist/components.js +11 -11
- package/dist/components.js.map +1 -1
- package/dist/components.umd.js +5 -5
- package/dist/components.umd.js.map +1 -1
- package/dist/element.cjs +4 -4
- package/dist/element.cjs.map +1 -1
- package/dist/element.d.cts +5 -5
- package/dist/element.d.ts +5 -5
- package/dist/element.js +4 -4
- package/dist/element.js.map +1 -1
- package/dist/element.umd.js.map +1 -1
- package/dist/index.cjs +10 -10
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +9 -9
- package/dist/index.d.ts +9 -9
- package/dist/index.js +11 -11
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +3 -3
- package/dist/index.umd.js.map +1 -1
- package/dist/presets/extended.cjs +3 -3
- package/dist/presets/extended.cjs.map +1 -1
- package/dist/presets/extended.d.cts +3 -3
- package/dist/presets/extended.d.ts +3 -3
- package/dist/presets/extended.js +3 -3
- package/dist/presets/extended.js.map +1 -1
- package/dist/presets-extended.umd.js.map +1 -1
- package/dist/react.cjs +4 -4
- package/dist/react.cjs.map +1 -1
- package/dist/react.d.cts +5 -5
- package/dist/react.d.ts +5 -5
- package/dist/react.js +4 -4
- package/dist/react.js.map +1 -1
- package/dist/solid.cjs +5 -5
- package/dist/solid.cjs.map +1 -1
- package/dist/solid.d.cts +6 -6
- package/dist/solid.d.ts +6 -6
- package/dist/solid.js +5 -5
- package/dist/solid.js.map +1 -1
- package/dist/svelte.cjs +5 -5
- package/dist/svelte.cjs.map +1 -1
- package/dist/svelte.d.cts +6 -6
- package/dist/svelte.d.ts +6 -6
- package/dist/svelte.js +5 -5
- package/dist/svelte.js.map +1 -1
- package/dist/vue.cjs +4 -4
- package/dist/vue.cjs.map +1 -1
- package/dist/vue.d.cts +5 -5
- package/dist/vue.d.ts +5 -5
- package/dist/vue.js +4 -4
- package/dist/vue.js.map +1 -1
- package/docs/API.md +13 -13
- package/docs/ROADMAP.md +2 -2
- package/docs/accessibility.md +2 -2
- package/docs/components.md +33 -33
- package/docs/frameworks-ssr.md +12 -12
- package/docs/hybrid-apps.md +10 -10
- package/docs/migration-from-aos.md +5 -5
- package/docs/migration-from-gsap-scrolltrigger.md +3 -3
- package/docs/motion-tokens.css +1 -1
- package/docs/motion-tokens.md +2 -2
- package/docs/performance.md +6 -6
- package/docs/presets.md +5 -5
- package/docs/windows-apps.md +8 -8
- package/package.json +26 -25
- package/dist/chunks/base-B5i8qQPR.cjs.map +0 -1
- package/dist/chunks/base-C3Sw9sAO.js.map +0 -1
- package/dist/chunks/core-BVQW34aX.js.map +0 -1
- package/dist/chunks/core-BYLtO0Po.cjs.map +0 -1
- package/dist/chunks/presets-BJ09NeTo.js.map +0 -1
- package/dist/chunks/presets-D2ksQNzJ.cjs.map +0 -1
- package/dist/chunks/stagger-CvhYlKrF.cjs.map +0 -1
- package/dist/chunks/stagger-Dh4V-OL0.js.map +0 -1
package/docs/API.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# API reference
|
|
2
2
|
|
|
3
|
-
`
|
|
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,24 +17,24 @@
|
|
|
17
17
|
|
|
18
18
|
| Import | Contents |
|
|
19
19
|
|---|---|
|
|
20
|
-
| `
|
|
21
|
-
| `
|
|
22
|
-
| `
|
|
23
|
-
| `
|
|
24
|
-
| `
|
|
25
|
-
| `
|
|
26
|
-
| `
|
|
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>` |
|
|
27
27
|
| `dist/index.umd.js` | Global `ScrollAnimate` (`ScrollAnimate.default` is the instance, other exports as properties) |
|
|
28
28
|
| `dist/element.umd.js` | Registers `<scroll-animate>` on load; global `ScrollAnimateElement` |
|
|
29
|
-
| `
|
|
30
|
-
| `dist/components.umd.js`, `
|
|
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 |
|
|
31
31
|
|
|
32
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.
|
|
33
33
|
|
|
34
34
|
## Default instance & `createScrollAnimate(config)`
|
|
35
35
|
|
|
36
36
|
```ts
|
|
37
|
-
import ScrollAnimate, { createScrollAnimate } from '
|
|
37
|
+
import ScrollAnimate, { createScrollAnimate } from 'motionary';
|
|
38
38
|
|
|
39
39
|
ScrollAnimate.init(); // shared default instance
|
|
40
40
|
const sa = createScrollAnimate({ defaultDuration: 800, defaultEngine: 'auto' }); // isolated instance
|
|
@@ -105,7 +105,7 @@ Boolean attributes are true when present unless their value is `"false"`.
|
|
|
105
105
|
|
|
106
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
107
|
|
|
108
|
-
**Extended presets (6.1)** — 181 more after `import '
|
|
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
109
|
|
|
110
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%'] }`.
|
|
111
111
|
|
|
@@ -117,7 +117,7 @@ Boolean attributes are true when present unless their value is `"false"`.
|
|
|
117
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.
|
|
118
118
|
|
|
119
119
|
### `timeline(options?)` → `Timeline` (4.0; replaces `sequence()`)
|
|
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 `
|
|
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>`.
|
|
121
121
|
|
|
122
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"`).
|
|
123
123
|
|
package/docs/ROADMAP.md
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
# 路线图(6.0 之后)
|
|
2
2
|
|
|
3
|
-
> 6.0.0:移除 5.9 弃用的 API(`burst()` / `confetti()` / `shake()`、`<usa-cursor mode="trail">`),所有效果统一通过注册表(`registerEffect()` / `playEffect()` / `<usa-fx>`)提供。以下为 6.x → 7.0 的规划,每个版本一个 PR(6.1 插入“滚动预设 2.0”后,原 6.1–6.9 依次顺延为 6.2–6.10);新效果继续集中在 `
|
|
3
|
+
> 6.0.0:移除 5.9 弃用的 API(`burst()` / `confetti()` / `shake()`、`<usa-cursor mode="trail">`),所有效果统一通过注册表(`registerEffect()` / `playEffect()` / `<usa-fx>`)提供。以下为 6.x → 7.0 的规划,每个版本一个 PR(6.1 插入“滚动预设 2.0”后,原 6.1–6.9 依次顺延为 6.2–6.10);新效果继续集中在 `motionary/components/effects`(`components/lite` 维持 70 KB 预算),全部兼容“减少动态效果”。
|
|
4
4
|
|
|
5
|
-
- **v6.1** ✅ — 滚动预设 2.0(Scroll presets 2.0,已发布):新增 181 个滚动入场预设(总计 214 个),独立入口 `
|
|
5
|
+
- **v6.1** ✅ — 滚动预设 2.0(Scroll presets 2.0,已发布):新增 181 个滚动入场预设(总计 214 个),独立入口 `motionary/presets/extended`(导入即注册,UMD `dist/presets-extended.umd.js`),核心包体积不变;预设支持中间关键帧 `frames`,新增 `registerPresets()` / `reversePreset()`;动画商店扩展到 227 个条目、14 个预设分类(含随滚动 `scrub-*` 与错峰 `stagger-*`)。
|
|
6
6
|
- **v6.2** — 粒子与流体 2.0:GPU 流体模拟背景、烟雾与火焰、墨滴扩散、萤火虫群、樱花与落叶飘散、点击溅起水花 —— WebGL2 实现,自动降级到 Canvas 2D。
|
|
7
7
|
- **v6.3** — 文字特效 3.0:液态文字、霓虹描边书写、文字粒子化聚散、故障(glitch)字、打字机光标拖影、可变字体呼吸、逐字 3D 翻转。
|
|
8
8
|
- **v6.4** — 光影与材质:动态光源投影、玻璃折射、金属拉丝反光、珠光 / 镭射材质、体积光(god rays)、跟随指针的实时阴影。
|
package/docs/accessibility.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Accessibility (`
|
|
1
|
+
# Accessibility (`motionary/components`)
|
|
2
2
|
|
|
3
3
|
Audited in v2.9 (automated sweep in `test/components-a11y-frameworks.test.ts` + per-component tests).
|
|
4
4
|
|
|
@@ -33,7 +33,7 @@ Glass, acrylic and Fluent materials fall back to solid surfaces under `prefers-r
|
|
|
33
33
|
|
|
34
34
|
## Motion-sensitivity levels (4.4)
|
|
35
35
|
|
|
36
|
-
`import { setMotionSensitivity, restoreMotionSensitivity } from '
|
|
36
|
+
`import { setMotionSensitivity, restoreMotionSensitivity } from 'motionary/components/a11y'`
|
|
37
37
|
|
|
38
38
|
| Level | What moves | Use for |
|
|
39
39
|
|---|---|---|
|
package/docs/components.md
CHANGED
|
@@ -1,55 +1,55 @@
|
|
|
1
|
-
# Animated components (`
|
|
1
|
+
# Animated components (`motionary/components`)
|
|
2
2
|
|
|
3
3
|
Since **v2.2** (now **v3**) the package ships **30 animated UI components** as standard Web Components (`<usa-*>` custom elements) plus three transition helpers. They are built only on Custom Elements, CSS and the Web Animations API, so the same code runs:
|
|
4
4
|
|
|
5
5
|
- in any modern browser (Chrome, Edge, Firefox, Safari), and with React, Vue, Svelte, Solid, Angular or no framework;
|
|
6
6
|
- in **Windows desktop software** that renders its UI with a web view — Electron, Tauri (WebView2), WinUI 3 / WPF / WinForms with WebView2, and installed PWAs. See **[Windows apps guide](./windows-apps.md)**.
|
|
7
7
|
|
|
8
|
-
Live gallery: <https://harrisoncn.github.io/
|
|
8
|
+
Live gallery: <https://harrisoncn.github.io/motionary/showcase/components.html>
|
|
9
9
|
|
|
10
10
|
## Principles
|
|
11
11
|
|
|
12
|
-
- **Zero dependencies, tree-shakable.** Import one category (`
|
|
12
|
+
- **Zero dependencies, tree-shakable.** Import one category (`motionary/components/text`) or one component (`import { defineTypewriter } …`) and only that ships.
|
|
13
13
|
- **SSR-safe.** Importing never touches `window`/`document`; every `define*()` is a no-op on the server.
|
|
14
14
|
- **Opt-in registration.** Nothing is registered until you call `define*()` (or load the IIFE bundle). Every `define*()` accepts a custom tag name: `defineSpinner('my-loader')`.
|
|
15
15
|
- **`prefers-reduced-motion` everywhere.** Each component has a calm variant (instant reveal, fade instead of slide, static background…). Override globally with `configureComponents({ reducedMotion: 'reduce' | 'no-preference' | 'user' })`.
|
|
16
16
|
- **GPU-friendly.** Animations use `transform` / `opacity` (plus `filter` for blur effects); layout is read and written in separate phases, at most once per frame, and loops pause when off-screen or the tab is hidden.
|
|
17
17
|
- **Accessible.** Animated text keeps a visually-hidden plain copy for screen readers; switches, progress bars, toasts and dialogs carry the right roles and ARIA states.
|
|
18
|
-
- **Styles included.** Each component injects its own small stylesheet once (as a constructable stylesheet, which a `style-src 'self'` CSP allows). Prefer a file? `import '
|
|
18
|
+
- **Styles included.** Each component injects its own small stylesheet once (as a constructable stylesheet, which a `style-src 'self'` CSP allows). Prefer a file? `import 'motionary/components.css'` (or `/components/<category>.css`) and call `configureComponents({ injectStyles: false })`.
|
|
19
19
|
|
|
20
20
|
## Install & register
|
|
21
21
|
|
|
22
22
|
```bash
|
|
23
|
-
npm i
|
|
23
|
+
npm i motionary
|
|
24
24
|
```
|
|
25
25
|
|
|
26
26
|
```js
|
|
27
27
|
// everything
|
|
28
|
-
import { defineComponents } from '
|
|
28
|
+
import { defineComponents } from 'motionary/components';
|
|
29
29
|
defineComponents(); // or defineComponents(['text', 'feedback'])
|
|
30
30
|
|
|
31
31
|
// one category
|
|
32
|
-
import { defineTextComponents } from '
|
|
32
|
+
import { defineTextComponents } from 'motionary/components/text';
|
|
33
33
|
defineTextComponents();
|
|
34
34
|
|
|
35
35
|
// one component
|
|
36
|
-
import { defineTypewriter } from '
|
|
36
|
+
import { defineTypewriter } from 'motionary/components/text';
|
|
37
37
|
defineTypewriter();
|
|
38
38
|
```
|
|
39
39
|
|
|
40
40
|
No build step (registers every `<usa-*>` and exposes the API as `window.UsaComponents`):
|
|
41
41
|
|
|
42
42
|
```html
|
|
43
|
-
<script src="https://unpkg.com/
|
|
43
|
+
<script src="https://unpkg.com/motionary@6/dist/components.umd.js"></script>
|
|
44
44
|
<usa-typewriter words="Hello, Windows.|Hello, web."></usa-typewriter>
|
|
45
45
|
<script>UsaComponents.toast('Ready', { type: 'success' });</script>
|
|
46
46
|
```
|
|
47
47
|
|
|
48
48
|
| Entry | Contents |
|
|
49
49
|
|---|---|
|
|
50
|
-
| `
|
|
51
|
-
| `
|
|
52
|
-
| `
|
|
50
|
+
| `motionary/components` | everything + `defineComponents()`, `COMPONENT_CATEGORIES`, `configureComponents()` |
|
|
51
|
+
| `motionary/components/reveal` · `/text` · `/interaction` · `/feedback` · `/background` · `/transitions` | one category + `define<Category>Components()` |
|
|
52
|
+
| `motionary/components.css`, `/components/<category>.css` | the same styles as files |
|
|
53
53
|
| `dist/components.umd.js` | IIFE/UMD bundle for `<script>` tags, auto-registers |
|
|
54
54
|
|
|
55
55
|
## Components by category
|
|
@@ -60,7 +60,7 @@ All attributes are optional unless noted. Events are `CustomEvent`s that bubble,
|
|
|
60
60
|
|
|
61
61
|
| Element | What it does | Key attributes | JS API / events |
|
|
62
62
|
|---|---|---|---|
|
|
63
|
-
| `<usa-reveal>` | Reveals content when it enters the viewport | `effect` (`fade`, `fade-up`*, `fade-down`, `fade-left`, `fade-right`, `zoom-in`, `zoom-out`, `blur`, `blur-up`, `flip-up`, `flip-left`, `rise`, or since 6.1 any registered scroll preset name such as `bounce-in-up` / `clip-diamond` once `
|
|
63
|
+
| `<usa-reveal>` | Reveals content when it enters the viewport | `effect` (`fade`, `fade-up`*, `fade-down`, `fade-left`, `fade-right`, `zoom-in`, `zoom-out`, `blur`, `blur-up`, `flip-up`, `flip-left`, `rise`, or since 6.1 any registered scroll preset name such as `bounce-in-up` / `clip-diamond` once `motionary` or `motionary/presets/extended` is loaded — see [presets.md](./presets.md)), `duration` (700), `delay`, `distance` (32), `easing`, `threshold` (0.15), `root-margin`, `repeat` | `reveal()`, `reset()`, `revealed`; `usa:enter`, `usa:leave`, `usa:complete` |
|
|
64
64
|
| `<usa-stagger>` | Reveals its children one after another | `effect`, `interval` (70 ms), `duration`, `delay`, `distance`, `threshold`, `repeat` | `reveal()`, `reset()`; `usa:enter`, `usa:complete` |
|
|
65
65
|
| `<usa-scroll-progress>` | Reading-progress bar for the page or one article | `target` (selector), `position` (`top`*, `bottom`, `inline`), `label`; CSS `--usa-progress-color/-height/-track` | `progress`, `update()`; `usa:progress` (`detail.progress`); `--usa-progress` on the element |
|
|
66
66
|
| `<usa-scrolly>` | Sticky scrollytelling: `[data-sticky]` stays pinned while `[data-step]` children scroll by | `offset` (trigger line, 0.5) | `active`, `steps`; `usa:step` (`detail.index/step/name`); `data-step-name` + `--usa-step` on the host, `data-active` on the step |
|
|
@@ -222,10 +222,10 @@ Every component reads these CSS custom properties (set them on `:root`, any ance
|
|
|
222
222
|
|
|
223
223
|
| Import | What |
|
|
224
224
|
|---|---|
|
|
225
|
-
| `
|
|
226
|
-
| `
|
|
227
|
-
| `
|
|
228
|
-
| `
|
|
225
|
+
| `motionary/components/react` | `createUsaComponents(React)` typed wrappers (props, ref, `onUsa*` events) |
|
|
226
|
+
| `motionary/components/vue` | `isUsaElement`, `UsaPlugin` |
|
|
227
|
+
| `motionary/components/jsx` | `UsaIntrinsicElements` JSX types |
|
|
228
|
+
| `motionary/components/lazy` | `lazyDefine()`, `defineUsed()`, `loadCategory()` |
|
|
229
229
|
|
|
230
230
|
See [frameworks-ssr.md](./frameworks-ssr.md) and [accessibility.md](./accessibility.md).
|
|
231
231
|
|
|
@@ -327,7 +327,7 @@ Hybrid / desktop hosts (MAUI, Flutter WebView, Electron, Tauri): [hybrid-apps.md
|
|
|
327
327
|
`<usa-fx>` (`defineFx()`, `defineFxComponents()`) plays any registered effect on its first child: `<usa-fx effect="jelly" trigger="click"><button>Go</button></usa-fx>` — `trigger` `click` · `hover` · `enter` · `load` · `loop` · `manual`, `options` (JSON), `once`, `self`.
|
|
328
328
|
|
|
329
329
|
```js
|
|
330
|
-
import { registerEffect, playEffect, bindEffect, listEffects } from '
|
|
330
|
+
import { registerEffect, playEffect, bindEffect, listEffects } from 'motionary/components/fx';
|
|
331
331
|
registerEffect({ name: 'spin-pop', kind: 'attention', run: (el, o, ctx) => ctx.animate(el, frames, { duration: 700 }) });
|
|
332
332
|
await playEffect(el, 'spin-pop');
|
|
333
333
|
const unbind = bindEffect(card, 'fade-up', { trigger: 'enter' });
|
|
@@ -337,10 +337,10 @@ Built-ins (`BUILTIN_EFFECTS`): every timeline preset as an `enter` effect (`fade
|
|
|
337
337
|
|
|
338
338
|
### v5.1 Card & click effects 2.0 (`components/effects`)
|
|
339
339
|
|
|
340
|
-
The 5.x effect packs live in `
|
|
340
|
+
The 5.x effect packs live in `motionary/components/effects` (not in `components` / `components/lite`). Register them once, then use any name with `<usa-fx>`, `playEffect()` or `bindEffect()`:
|
|
341
341
|
|
|
342
342
|
```js
|
|
343
|
-
import { registerAllEffects } from '
|
|
343
|
+
import { registerAllEffects } from 'motionary/components/effects';
|
|
344
344
|
registerAllEffects();
|
|
345
345
|
```
|
|
346
346
|
```html
|
|
@@ -355,7 +355,7 @@ Card: `holo` · `glare-sweep` · `book-open` · `card-fan` · `topple` · `float
|
|
|
355
355
|
`bounce-in` · `rubber-band` · `elastic-hover` · `drop-bounce` · `gravity-text` · `spring-follow` · `bell-swing` — keyframes come from a damped-spring / gravity solver and play on WAAPI.
|
|
356
356
|
|
|
357
357
|
```js
|
|
358
|
-
import { registerAllEffects, solveSpring, springKeyframes } from '
|
|
358
|
+
import { registerAllEffects, solveSpring, springKeyframes } from 'motionary/components/effects';
|
|
359
359
|
registerAllEffects();
|
|
360
360
|
const { frames, duration } = springKeyframes((p) => ({ transform: `scale(${p})` }), { stiffness: 220, damping: 11 });
|
|
361
361
|
el.animate(frames, { duration });
|
|
@@ -370,8 +370,8 @@ el.animate(frames, { duration });
|
|
|
370
370
|
Transitions `curtain` · `iris` · `pixel-dissolve` · `blinds` cover the viewport, await `onCovered()`, then reveal:
|
|
371
371
|
|
|
372
372
|
```js
|
|
373
|
-
import { registerAllEffects } from '
|
|
374
|
-
import { playEffect } from '
|
|
373
|
+
import { registerAllEffects } from 'motionary/components/effects';
|
|
374
|
+
import { playEffect } from 'motionary/components/fx';
|
|
375
375
|
registerAllEffects();
|
|
376
376
|
link.addEventListener('click', (e) => {
|
|
377
377
|
e.preventDefault();
|
|
@@ -384,7 +384,7 @@ Persistent: `<usa-fx effect="velocity-skew" trigger="load">`, `spotlight` (`radi
|
|
|
384
384
|
### v5.4 Scroll stories — `<usa-story>` (`components/effects`)
|
|
385
385
|
|
|
386
386
|
```js
|
|
387
|
-
import { defineStory } from '
|
|
387
|
+
import { defineStory } from 'motionary/components/effects';
|
|
388
388
|
defineStory();
|
|
389
389
|
```
|
|
390
390
|
```html
|
|
@@ -410,8 +410,8 @@ Templates `pin` · `gallery` · `zoom` (`zoom="6"`) · `compare` · `counter` ·
|
|
|
410
410
|
</usa-fx>
|
|
411
411
|
```
|
|
412
412
|
```js
|
|
413
|
-
import { registerEffect } from '
|
|
414
|
-
import { canvasBackground } from '
|
|
413
|
+
import { registerEffect } from 'motionary/components/fx';
|
|
414
|
+
import { canvasBackground } from 'motionary/components/effects';
|
|
415
415
|
registerEffect({ name: 'pulse-bg', kind: 'background', reduced: 'run',
|
|
416
416
|
run: (el, o, ctx) => canvasBackground(el, ctx, { draw: ({ ctx: g, w, h, t }) => { g.fillStyle = `hsl(${t * 40} 70% 50%)`; g.fillRect(0, 0, w, h); } }, o) });
|
|
417
417
|
```
|
|
@@ -428,7 +428,7 @@ registerEffect({ name: 'pulse-bg', kind: 'background', reduced: 'run',
|
|
|
428
428
|
</usa-audio>
|
|
429
429
|
```
|
|
430
430
|
```js
|
|
431
|
-
import { enableAudio, bindBeat, registerAllEffects } from '
|
|
431
|
+
import { enableAudio, bindBeat, registerAllEffects } from 'motionary/components/effects';
|
|
432
432
|
registerAllEffects();
|
|
433
433
|
button.addEventListener('click', async () => {
|
|
434
434
|
await enableAudio('mic'); // or an <audio>/<video> element, selector or MediaStream
|
|
@@ -446,7 +446,7 @@ Cursor effects (`comet-trail` · `ribbon-trail` · `sparkle-trail` · `magnetic-
|
|
|
446
446
|
<usa-gesture-fx gesture="long-press" effect="tada"><button>Hold me</button></usa-gesture-fx>
|
|
447
447
|
```
|
|
448
448
|
```js
|
|
449
|
-
import { bindGesture, registerAllEffects } from '
|
|
449
|
+
import { bindGesture, registerAllEffects } from 'motionary/components/effects';
|
|
450
450
|
registerAllEffects();
|
|
451
451
|
bindGesture(card, 'fling', 'confetti', { velocity: 1 });
|
|
452
452
|
bindGesture(dial, 'twist', ({ direction }) => step(direction === 'cw' ? 1 : -1));
|
|
@@ -460,12 +460,12 @@ bindGesture(dial, 'twist', ({ direction }) => step(direction === 'cw' ? 1 : -1))
|
|
|
460
460
|
<div class="usa-surface">
|
|
461
461
|
<button data-theme-fx="click">Tap</button>
|
|
462
462
|
<usa-fx effect="like-heart" trigger="click"><button aria-pressed="false">♥ <span data-count="12">12</span></button></usa-fx>
|
|
463
|
-
<usa-fx effect="copy-success" trigger="click"><button data-copy="npm i
|
|
463
|
+
<usa-fx effect="copy-success" trigger="click"><button data-copy="npm i motionary">Copy</button></usa-fx>
|
|
464
464
|
</div>
|
|
465
465
|
</usa-theme>
|
|
466
466
|
```
|
|
467
467
|
```js
|
|
468
|
-
import { applyTheme, themeCss, playEffect, registerAllEffects } from '
|
|
468
|
+
import { applyTheme, themeCss, playEffect, registerAllEffects } from 'motionary/components/effects';
|
|
469
469
|
registerAllEffects();
|
|
470
470
|
const undo = applyTheme('neon'); // whole page: design + motion tokens + data-usa-theme
|
|
471
471
|
const css = themeCss('paper', ':root'); // static CSS for SSR
|
|
@@ -492,7 +492,7 @@ Plays JSON animations made of timeline presets, keyframes and registered effects
|
|
|
492
492
|
</usa-player>
|
|
493
493
|
```
|
|
494
494
|
```js
|
|
495
|
-
import { createPlayer, registerAllEffects } from '
|
|
495
|
+
import { createPlayer, registerAllEffects } from 'motionary/components/effects';
|
|
496
496
|
registerAllEffects();
|
|
497
497
|
const p = createPlayer(hero, await (await fetch('/hero.json')).json());
|
|
498
498
|
p.play(); p.seek(500); p.rate = 0.5;
|
|
@@ -505,7 +505,7 @@ Custom elements work in every framework. Register once (e.g. in your entry file)
|
|
|
505
505
|
|
|
506
506
|
```jsx
|
|
507
507
|
// React 19 passes props to custom elements as properties; React 18 passes strings — both work for attributes.
|
|
508
|
-
import { defineFeedbackComponents, toast } from '
|
|
508
|
+
import { defineFeedbackComponents, toast } from 'motionary/components/feedback';
|
|
509
509
|
defineFeedbackComponents();
|
|
510
510
|
|
|
511
511
|
export function Save() {
|
|
@@ -532,4 +532,4 @@ Gzipped, minified (budgets enforced in CI by `npm run size:check`):
|
|
|
532
532
|
| `viewTransition` only | ≈ 0.4 kB |
|
|
533
533
|
| `dist/components.css` | ≈ 5.5 kB |
|
|
534
534
|
|
|
535
|
-
The scroll-animation core (`
|
|
535
|
+
The scroll-animation core (`motionary`) is unchanged and is not pulled in by the components.
|
package/docs/frameworks-ssr.md
CHANGED
|
@@ -8,22 +8,22 @@ All entry points are **SSR-safe**: importing never touches `window`/`document`;
|
|
|
8
8
|
'use client';
|
|
9
9
|
import { useEffect } from 'react';
|
|
10
10
|
export function UsaProvider() {
|
|
11
|
-
useEffect(() => { import('
|
|
11
|
+
useEffect(() => { import('motionary/components/lazy').then((m) => m.lazyDefine()); }, []);
|
|
12
12
|
return null;
|
|
13
13
|
}
|
|
14
14
|
// app/layout.tsx → <body><UsaProvider />{children}</body>
|
|
15
15
|
```
|
|
16
|
-
The raw tags render on the server as plain HTML and upgrade on hydration. Type them with `
|
|
16
|
+
The raw tags render on the server as plain HTML and upgrade on hydration. Type them with `motionary/components/jsx`:
|
|
17
17
|
```ts
|
|
18
18
|
// usa-jsx.d.ts
|
|
19
|
-
import type { UsaIntrinsicElements } from '
|
|
19
|
+
import type { UsaIntrinsicElements } from 'motionary/components/jsx';
|
|
20
20
|
declare module 'react' { namespace JSX { interface IntrinsicElements extends UsaIntrinsicElements {} } }
|
|
21
21
|
```
|
|
22
22
|
Prefer typed wrappers (React 18 sets properties & `usa:*` events for you):
|
|
23
23
|
```tsx
|
|
24
24
|
'use client';
|
|
25
25
|
import * as React from 'react';
|
|
26
|
-
import { createUsaComponents } from '
|
|
26
|
+
import { createUsaComponents } from 'motionary/components/react';
|
|
27
27
|
export const { UsaButton, UsaToggle, UsaCard } = createUsaComponents(React);
|
|
28
28
|
// <UsaToggle checked={on} onUsaChange={(e) => setOn(e.detail.checked)} />
|
|
29
29
|
```
|
|
@@ -37,8 +37,8 @@ Page transitions in the App Router: wrap `router.push` in `pageTransition(() =>
|
|
|
37
37
|
<html><body>
|
|
38
38
|
<slot />
|
|
39
39
|
<script>
|
|
40
|
-
import { lazyDefine } from '
|
|
41
|
-
import { enableMpaTransitions } from '
|
|
40
|
+
import { lazyDefine } from 'motionary/components/lazy';
|
|
41
|
+
import { enableMpaTransitions } from 'motionary/components/page';
|
|
42
42
|
lazyDefine();
|
|
43
43
|
enableMpaTransitions('fade'); // cross-page View Transitions (or use Astro's <ClientRouter />)
|
|
44
44
|
</script>
|
|
@@ -49,10 +49,10 @@ Use the tags directly in `.astro`, `.md` and island components. With `<ClientRou
|
|
|
49
49
|
## Vue / Nuxt
|
|
50
50
|
```js
|
|
51
51
|
// vite.config.js
|
|
52
|
-
import { isUsaElement } from '
|
|
52
|
+
import { isUsaElement } from 'motionary/components/vue';
|
|
53
53
|
vue({ template: { compilerOptions: { isCustomElement: isUsaElement } } });
|
|
54
54
|
// main.js (or a Nuxt client plugin: plugins/usa.client.ts)
|
|
55
|
-
import { UsaPlugin } from '
|
|
55
|
+
import { UsaPlugin } from 'motionary/components/vue';
|
|
56
56
|
app.use(UsaPlugin); // or app.use(UsaPlugin, { categories: ['click', 'ui'] })
|
|
57
57
|
```
|
|
58
58
|
`<usa-toggle :checked.prop="on" @usa:change="on = $event.detail.checked" />`
|
|
@@ -61,14 +61,14 @@ app.use(UsaPlugin); // or app.use(UsaPlugin, { categories: ['click',
|
|
|
61
61
|
Custom elements work as-is: Svelte (`on:usa:change`), Solid (`on:usa:change`, `prop:checked`), Angular (`schemas: [CUSTOM_ELEMENTS_SCHEMA]`). Call `defineComponents()` or `lazyDefine()` in the client entry.
|
|
62
62
|
|
|
63
63
|
## Lazy registration
|
|
64
|
-
`lazyDefine()` (from `
|
|
64
|
+
`lazyDefine()` (from `motionary/components/lazy`) watches the DOM and dynamically imports only the categories whose tags appear — a page with just `<usa-button>` loads the click chunk only.
|
|
65
65
|
|
|
66
66
|
## Svelte / SvelteKit (v3.8)
|
|
67
67
|
|
|
68
68
|
```svelte
|
|
69
69
|
<script>
|
|
70
70
|
import { onMount } from 'svelte';
|
|
71
|
-
import { usa, defineUsa } from '
|
|
71
|
+
import { usa, defineUsa } from 'motionary/components/svelte';
|
|
72
72
|
onMount(() => defineUsa());
|
|
73
73
|
let on = false;
|
|
74
74
|
</script>
|
|
@@ -79,7 +79,7 @@ Custom elements work as-is: Svelte (`on:usa:change`), Solid (`on:usa:change`, `p
|
|
|
79
79
|
|
|
80
80
|
```tsx
|
|
81
81
|
import { onMount } from 'solid-js';
|
|
82
|
-
import { defineUsa } from '
|
|
82
|
+
import { defineUsa } from 'motionary/components/solid';
|
|
83
83
|
onMount(() => defineUsa());
|
|
84
84
|
<usa-toggle prop:checked={on()} on:usa:change={(e) => setOn(e.detail.checked)} />;
|
|
85
85
|
```
|
|
@@ -88,7 +88,7 @@ onMount(() => defineUsa());
|
|
|
88
88
|
|
|
89
89
|
```ts
|
|
90
90
|
import { APP_INITIALIZER, CUSTOM_ELEMENTS_SCHEMA, Component } from '@angular/core';
|
|
91
|
-
import { usaInitializer, usaDetail } from '
|
|
91
|
+
import { usaInitializer, usaDetail } from 'motionary/components/angular';
|
|
92
92
|
// app.config.ts
|
|
93
93
|
providers: [{ provide: APP_INITIALIZER, multi: true, useFactory: usaInitializer() }];
|
|
94
94
|
// component
|
package/docs/hybrid-apps.md
CHANGED
|
@@ -17,7 +17,7 @@ MAUI 9+ has `HybridWebView` (raw HTML + JS bridge); `BlazorWebView` also works (
|
|
|
17
17
|
```text
|
|
18
18
|
Resources/Raw/wwwroot/
|
|
19
19
|
index.html
|
|
20
|
-
components.umd.js ← copied from node_modules/
|
|
20
|
+
components.umd.js ← copied from node_modules/motionary/dist/
|
|
21
21
|
```
|
|
22
22
|
|
|
23
23
|
```xml
|
|
@@ -84,7 +84,7 @@ The renderer is Chromium — use the npm package with your bundler, or the UMD f
|
|
|
84
84
|
|
|
85
85
|
```js
|
|
86
86
|
// renderer.js (bundled)
|
|
87
|
-
import { defineComponents, configureComponents } from '
|
|
87
|
+
import { defineComponents, configureComponents } from 'motionary/components';
|
|
88
88
|
configureComponents({ injectStyles: true });
|
|
89
89
|
defineComponents();
|
|
90
90
|
```
|
|
@@ -106,7 +106,7 @@ Imports are SSR-safe (no `window` access at import time), so the same modules ca
|
|
|
106
106
|
|
|
107
107
|
```js
|
|
108
108
|
// src/main.js (Vite)
|
|
109
|
-
import { defineComponents } from '
|
|
109
|
+
import { defineComponents } from 'motionary/components';
|
|
110
110
|
import { invoke } from '@tauri-apps/api/core';
|
|
111
111
|
defineComponents();
|
|
112
112
|
document.querySelector('usa-toggle').addEventListener('usa:change', (e) => invoke('set_setting', { on: e.detail.checked }));
|
|
@@ -121,10 +121,10 @@ Tauri uses WebView2 on Windows, WKWebView on macOS / iOS and WebKitGTK on Linux.
|
|
|
121
121
|
|
|
122
122
|
## Native shell bridge (4.7)
|
|
123
123
|
|
|
124
|
-
`
|
|
124
|
+
`motionary/components/bridge` keeps the page in sync with the host app's **system settings** — reduce motion, light / dark / high-contrast theme, accent color — on WinUI 3 / WPF (WebView2), .NET MAUI and Flutter:
|
|
125
125
|
|
|
126
126
|
```js
|
|
127
|
-
import { connectNativeShell } from '
|
|
127
|
+
import { connectNativeShell } from 'motionary/components/bridge';
|
|
128
128
|
const { host } = connectNativeShell(); // 'webview2' | 'maui' | 'flutter' | 'electron' | 'tauri' | 'browser'
|
|
129
129
|
```
|
|
130
130
|
|
|
@@ -138,8 +138,8 @@ Helpers: `detectNativeHost()`, `postToNative(msg)`, `parseNativeSettings(data)`,
|
|
|
138
138
|
|
|
139
139
|
| Framework | Entry | What it gives you |
|
|
140
140
|
|---|---|---|
|
|
141
|
-
| React | `
|
|
142
|
-
| Vue | `
|
|
143
|
-
| Svelte | `
|
|
144
|
-
| Solid | `
|
|
145
|
-
| Angular | `
|
|
141
|
+
| React | `motionary/components/react` | `createUsaComponents(React)` typed wrappers |
|
|
142
|
+
| Vue | `motionary/components/vue` | `UsaPlugin`, `isUsaElement` |
|
|
143
|
+
| Svelte | `motionary/components/svelte` | `use:usa={{ props, on }}` action, `defineUsa()` |
|
|
144
|
+
| Solid | `motionary/components/solid` | `use:usa` directive, `defineUsa()`, JSX types |
|
|
145
|
+
| Angular | `motionary/components/angular` | `usaInitializer()` for `APP_INITIALIZER`, `usaDetail()`; use `CUSTOM_ELEMENTS_SCHEMA` |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Migrating from AOS (Animate On Scroll)
|
|
2
2
|
|
|
3
|
-
AOS and `
|
|
3
|
+
AOS and `motionary` work the same way at the markup level — mark elements with attributes and call `init()` — so most pages migrate with a search-and-replace.
|
|
4
4
|
|
|
5
5
|
## 1. Install and initialise
|
|
6
6
|
|
|
@@ -8,7 +8,7 @@ AOS and `use-scroll-animate` work the same way at the markup level — mark elem
|
|
|
8
8
|
- import AOS from 'aos';
|
|
9
9
|
- import 'aos/dist/aos.css';
|
|
10
10
|
- AOS.init({ duration: 800, once: true, offset: 120 });
|
|
11
|
-
+ import ScrollAnimate from '
|
|
11
|
+
+ import ScrollAnimate from 'motionary';
|
|
12
12
|
+ ScrollAnimate.configure({ defaultDuration: 800, defaultOnce: true, defaultOffset: 120 });
|
|
13
13
|
+ ScrollAnimate.watch(); // like init(), and also picks up elements added later (AOS.refreshHard())
|
|
14
14
|
```
|
|
@@ -17,7 +17,7 @@ No stylesheet is needed: animations run through the Web Animations API (or opt i
|
|
|
17
17
|
|
|
18
18
|
## 2. Attributes
|
|
19
19
|
|
|
20
|
-
| AOS |
|
|
20
|
+
| AOS | motionary |
|
|
21
21
|
|---|---|
|
|
22
22
|
| `data-aos="fade-up"` | `data-sa data-sa-animation="fade-in-up"` |
|
|
23
23
|
| `data-aos-duration="800"` | `data-sa-duration="800"` |
|
|
@@ -31,7 +31,7 @@ No stylesheet is needed: animations run through the Web Animations API (or opt i
|
|
|
31
31
|
|
|
32
32
|
## 3. Animation names
|
|
33
33
|
|
|
34
|
-
| AOS |
|
|
34
|
+
| AOS | motionary |
|
|
35
35
|
|---|---|
|
|
36
36
|
| `fade` | `fade-in` |
|
|
37
37
|
| `fade-up` / `fade-down` | `fade-in-up` / `fade-in-down` |
|
|
@@ -57,7 +57,7 @@ No stylesheet is needed: animations run through the Web Animations API (or opt i
|
|
|
57
57
|
|
|
58
58
|
## 5. Events and refresh
|
|
59
59
|
|
|
60
|
-
| AOS |
|
|
60
|
+
| AOS | motionary |
|
|
61
61
|
|---|---|
|
|
62
62
|
| `document.addEventListener('aos:in', ...)` | `onEnter` / `onStart` options, or `<scroll-animate>`'s `sa:enter` / `sa:start` events |
|
|
63
63
|
| `aos:out` | `onLeave` |
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Migrating from GSAP ScrollTrigger
|
|
2
2
|
|
|
3
|
-
GSAP + ScrollTrigger is a full animation platform; `
|
|
3
|
+
GSAP + ScrollTrigger is a full animation platform; `motionary` covers the common scroll cases — reveal on enter, staggered lists, timelines, scrubbed progress and parallax — in a few kB with no dependencies. If you rely on pinning, `snap`, morphing or arbitrary property tweens, keep GSAP for those parts.
|
|
4
4
|
|
|
5
5
|
## Reveal on enter
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ GSAP + ScrollTrigger is a full animation platform; `use-scroll-animate` covers t
|
|
|
9
9
|
+ ScrollAnimate.observe('.card', { animation: 'fade-in-up', duration: 600 });
|
|
10
10
|
```
|
|
11
11
|
|
|
12
|
-
| ScrollTrigger |
|
|
12
|
+
| ScrollTrigger | motionary |
|
|
13
13
|
|---|---|
|
|
14
14
|
| `start: 'top 90%'` | `threshold` / `rootMargin` (`'0px 0px -10% 0px'`) or `offset` (px) |
|
|
15
15
|
| `once: true` | `once: true` (default) |
|
|
@@ -69,7 +69,7 @@ ScrollAnimate.observe('.card', { animation: 'zoom-in', engine: 'auto', viewRange
|
|
|
69
69
|
|
|
70
70
|
## Cleanup
|
|
71
71
|
|
|
72
|
-
| GSAP |
|
|
72
|
+
| GSAP | motionary |
|
|
73
73
|
|---|---|
|
|
74
74
|
| `ScrollTrigger.refresh()` | `refresh()` |
|
|
75
75
|
| `trigger.kill()` / `ScrollTrigger.getAll().forEach(t => t.kill())` | `unobserve(target)` / `destroy()` |
|
package/docs/motion-tokens.css
CHANGED
package/docs/motion-tokens.md
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
# Motion design tokens (4.2)
|
|
2
2
|
|
|
3
|
-
`
|
|
3
|
+
`motionary/components/tokens` gives your product one motion scale — durations, easings and springs — as **CSS custom properties**, **W3C Design Tokens JSON**, and **JS values**, and imports the scale your designers keep in **Figma Tokens (Tokens Studio)** or **Style Dictionary**.
|
|
4
4
|
|
|
5
5
|
```ts
|
|
6
|
-
import { applyMotionTokens, importMotionTokens, motionToken, motionVar } from '
|
|
6
|
+
import { applyMotionTokens, importMotionTokens, motionToken, motionVar } from 'motionary/components/tokens';
|
|
7
7
|
|
|
8
8
|
// 1. Use the defaults (writes --usa-* variables on <html>)…
|
|
9
9
|
applyMotionTokens();
|
package/docs/performance.md
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
Every `<usa-*>` loop (cursors, particles, springs, marquees, WebGL, scroll effects…) schedules work through **one shared `requestAnimationFrame`**: callbacks registered during a frame run together, in order, and a throwing callback no longer starves the rest. Use it for your own loops:
|
|
5
5
|
|
|
6
6
|
```ts
|
|
7
|
-
import { onFrame, schedulerStats } from '
|
|
7
|
+
import { onFrame, schedulerStats } from 'motionary/components/perf';
|
|
8
8
|
const stop = onFrame((time, dt) => { /* … */ });
|
|
9
9
|
schedulerStats(); // { frames, callbacks, peak, pending, loops }
|
|
10
10
|
```
|
|
@@ -13,12 +13,12 @@ schedulerStats(); // { frames, callbacks, peak, pending, loops }
|
|
|
13
13
|
- `setAnimationBudget(n)` caps concurrent component animations; extra ones land on their final frame instantly. `activeAnimations()` reports the current count.
|
|
14
14
|
- `autoDegrade({ minFps = 45, maxActive = 40, sample = 1000, patience = 2, recovery = 3 })` samples the frame rate and animation count. After `patience` bad samples it sets motion intensity to `low` and the budget to `maxActive / 2`; after `recovery` good samples it restores both. Dispatches `usa:degrade` (`{ degraded, fps, active, reason }`).
|
|
15
15
|
|
|
16
|
-
## On-demand CSS — `
|
|
17
|
-
Same API as `
|
|
16
|
+
## On-demand CSS — `motionary/components/lite`
|
|
17
|
+
Same API as `motionary/components`, but the light-DOM CSS is **not** inlined: the first time an element of a category connects, `dist/components/<category>.css` is added as a `<link>` (custom tag names fall back to `components.css`). Shadow-DOM styles stay inlined.
|
|
18
18
|
|
|
19
19
|
| Import | gzip |
|
|
20
20
|
|---|---|
|
|
21
|
-
| `
|
|
22
|
-
| `
|
|
21
|
+
| `motionary/components` (everything, CSS inlined) | ≈ 79 KB |
|
|
22
|
+
| `motionary/components/lite` (everything, CSS on demand) | **≈ 62 KB** (budget 70 KB, checked in CI) |
|
|
23
23
|
|
|
24
|
-
Serve the CSS from somewhere else with `onDemandStyles('https://cdn.example/
|
|
24
|
+
Serve the CSS from somewhere else with `onDemandStyles('https://cdn.example/motionary@6/dist/')`, or preload with `loadCategoryStyles('cards', base)`.
|
package/docs/presets.md
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
# Presets
|
|
2
2
|
|
|
3
|
-
`
|
|
3
|
+
`motionary` ships **214 scroll-reveal presets**: 33 in the core (always available) and **181 extended presets** added in 6.1 ("Scroll presets 2.0").
|
|
4
4
|
|
|
5
5
|
```js
|
|
6
|
-
import ScrollAnimate from '
|
|
7
|
-
import '
|
|
6
|
+
import ScrollAnimate from 'motionary';
|
|
7
|
+
import 'motionary/presets/extended'; // registers the extended set (≈ 4 kB gzip, separate entry)
|
|
8
8
|
|
|
9
9
|
ScrollAnimate.observe('.card', { animation: 'bounce-in-up', duration: 900 });
|
|
10
10
|
```
|
|
11
11
|
|
|
12
12
|
```html
|
|
13
13
|
<!-- No build: the UMD core, then the extended set (registers itself) -->
|
|
14
|
-
<script src="https://unpkg.com/
|
|
15
|
-
<script src="https://unpkg.com/
|
|
14
|
+
<script src="https://unpkg.com/motionary@6/dist/index.umd.js"></script>
|
|
15
|
+
<script src="https://unpkg.com/motionary@6/dist/presets-extended.umd.js"></script>
|
|
16
16
|
<div data-sa data-sa-animation="clip-diamond">…</div>
|
|
17
17
|
<script>ScrollAnimate.default.init();</script>
|
|
18
18
|
```
|