motionary 0.0.0-stage → 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 +784 -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-Yno7N2eC.js +404 -0
- package/dist/chunks/base-Yno7N2eC.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-BIOaYdgN.js +181 -0
- package/dist/chunks/core-BIOaYdgN.js.map +1 -0
- package/dist/chunks/core-CUGCsMsJ.js +260 -0
- package/dist/chunks/core-CUGCsMsJ.js.map +1 -0
- package/dist/chunks/core-D7cVumUu.js +909 -0
- package/dist/chunks/core-D7cVumUu.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-BqDeFywO.js +109 -0
- package/dist/chunks/fx-BqDeFywO.js.map +1 -0
- package/dist/chunks/fx-lBGVtQO1.cjs +114 -0
- package/dist/chunks/fx-lBGVtQO1.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/spring-DfQO5USi.js +219 -0
- package/dist/chunks/spring-DfQO5USi.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-VNscPeTD.js +35 -0
- package/dist/chunks/variants-VNscPeTD.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 +75 -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 +69 -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 +2590 -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 +2531 -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.cjs +289 -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 +275 -0
- package/dist/components/fx.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 +11099 -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 +10831 -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 +85 -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 +81 -0
- package/dist/components/solid.js.map +1 -0
- package/dist/components/svelte.cjs +67 -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 +63 -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 +66 -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 +63 -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.cjs +350 -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 +105 -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/docs/API.md +147 -0
- package/docs/ROADMAP.md +15 -0
- package/docs/accessibility.md +60 -0
- package/docs/components.md +535 -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 +532 -4
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { k as clamp } from './base-Yno7N2eC.js';
|
|
2
|
+
|
|
3
|
+
/** The swipe a pointer release represents, or `null` (pure). */
|
|
4
|
+
function swipeDirection(dx, dy, vx, vy, o = {}) {
|
|
5
|
+
const dist = o.distance ?? 40;
|
|
6
|
+
const vel = o.velocity ?? 300;
|
|
7
|
+
const horiz = o.axis === 'x' || (o.axis !== 'y' && Math.abs(dx) >= Math.abs(dy));
|
|
8
|
+
const d = horiz ? dx : dy;
|
|
9
|
+
const v = horiz ? vx : vy;
|
|
10
|
+
if (Math.abs(d) < dist && Math.abs(v) < vel * 2)
|
|
11
|
+
return null;
|
|
12
|
+
if (Math.abs(v) < vel && Math.abs(d) < dist * 3)
|
|
13
|
+
return null;
|
|
14
|
+
const direction = horiz ? (d > 0 ? 'right' : 'left') : d > 0 ? 'down' : 'up';
|
|
15
|
+
return { direction, velocity: Math.abs(v), dx, dy };
|
|
16
|
+
}
|
|
17
|
+
/** Scale between two pointer distances, clamped to [min, max] (pure). */
|
|
18
|
+
function pinchScale(startDistance, distance, base = 1, min = 0.5, max = 4) {
|
|
19
|
+
if (!startDistance)
|
|
20
|
+
return base;
|
|
21
|
+
return clamp(base * (distance / startDistance), min, max);
|
|
22
|
+
}
|
|
23
|
+
const pid = (e) => (typeof e.pointerId === 'number' ? e.pointerId : 1);
|
|
24
|
+
/**
|
|
25
|
+
* One recognizer for pan, swipe, pinch (two pointers or Ctrl + wheel),
|
|
26
|
+
* long-press, tap and double-tap, with velocities ready to hand to a spring
|
|
27
|
+
* (`createSpring().set(target, velocity)`). Works with mouse, touch and pen
|
|
28
|
+
* through Pointer Events. Returns a cleanup function.
|
|
29
|
+
*
|
|
30
|
+
* @example
|
|
31
|
+
* const x = createSpring({ onUpdate: (v) => (card.style.translate = `${v}px`) });
|
|
32
|
+
* gesture(card, {
|
|
33
|
+
* onPan: ({ dx, last, vx }) => (last ? x.set(0, vx) : x.jump(dx)),
|
|
34
|
+
* onSwipe: ({ direction }) => dismiss(direction),
|
|
35
|
+
* }, { axis: 'x' });
|
|
36
|
+
*/
|
|
37
|
+
function gesture(el, h, o = {}) {
|
|
38
|
+
const pts = new Map();
|
|
39
|
+
let start = { x: 0, y: 0 };
|
|
40
|
+
let last = { x: 0, y: 0, t: 0 };
|
|
41
|
+
let vx = 0;
|
|
42
|
+
let vy = 0;
|
|
43
|
+
let panning = false;
|
|
44
|
+
let pinch = null;
|
|
45
|
+
let pinchScaleNow = 1;
|
|
46
|
+
let press;
|
|
47
|
+
let pressed = false;
|
|
48
|
+
let lastTap = -1e9;
|
|
49
|
+
const th = o.threshold ?? 4;
|
|
50
|
+
const dist = () => {
|
|
51
|
+
const [a, b] = [...pts.values()];
|
|
52
|
+
return Math.hypot(a.x - b.x, a.y - b.y);
|
|
53
|
+
};
|
|
54
|
+
const mid = () => {
|
|
55
|
+
const [a, b] = [...pts.values()];
|
|
56
|
+
return { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };
|
|
57
|
+
};
|
|
58
|
+
const t = (e) => (e.timeStamp || Date.now());
|
|
59
|
+
const down = (e) => {
|
|
60
|
+
pts.set(pid(e), { x: e.clientX, y: e.clientY });
|
|
61
|
+
try {
|
|
62
|
+
el.setPointerCapture?.(pid(e));
|
|
63
|
+
}
|
|
64
|
+
catch { /* jsdom / synthetic */ }
|
|
65
|
+
if (pts.size === 2 && h.onPinch) {
|
|
66
|
+
clearTimeout(press);
|
|
67
|
+
if (panning)
|
|
68
|
+
h.onPan?.({ dx: last.x - start.x, dy: last.y - start.y, vx: 0, vy: 0, first: false, last: true, event: e });
|
|
69
|
+
panning = false;
|
|
70
|
+
pinch = { d0: dist(), first: true };
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
if (pts.size > 1)
|
|
74
|
+
return;
|
|
75
|
+
start = { x: e.clientX, y: e.clientY };
|
|
76
|
+
last = { ...start, t: t(e) };
|
|
77
|
+
vx = vy = 0;
|
|
78
|
+
pressed = false;
|
|
79
|
+
if (h.onLongPress)
|
|
80
|
+
press = setTimeout(() => { pressed = true; h.onLongPress?.({ x: start.x, y: start.y }); }, o.longPress ?? 500);
|
|
81
|
+
};
|
|
82
|
+
const move = (e) => {
|
|
83
|
+
if (!pts.has(pid(e)))
|
|
84
|
+
return;
|
|
85
|
+
pts.set(pid(e), { x: e.clientX, y: e.clientY });
|
|
86
|
+
if (pinch && pts.size >= 2) {
|
|
87
|
+
const m = mid();
|
|
88
|
+
pinchScaleNow = pinchScale(pinch.d0, dist(), 1, 0.05, 20);
|
|
89
|
+
h.onPinch?.({ scale: pinchScaleNow, x: m.x, y: m.y, first: pinch.first, last: false });
|
|
90
|
+
pinch.first = false;
|
|
91
|
+
return;
|
|
92
|
+
}
|
|
93
|
+
const dx = e.clientX - start.x;
|
|
94
|
+
const dy = e.clientY - start.y;
|
|
95
|
+
const dt = Math.max(1, t(e) - last.t) / 1000;
|
|
96
|
+
vx = (e.clientX - last.x) / dt;
|
|
97
|
+
vy = (e.clientY - last.y) / dt;
|
|
98
|
+
last = { x: e.clientX, y: e.clientY, t: t(e) };
|
|
99
|
+
if (!panning) {
|
|
100
|
+
const off = o.axis === 'x' ? Math.abs(dx) : o.axis === 'y' ? Math.abs(dy) : Math.hypot(dx, dy);
|
|
101
|
+
if (off < th)
|
|
102
|
+
return;
|
|
103
|
+
clearTimeout(press);
|
|
104
|
+
if (o.axis && Math.abs(o.axis === 'x' ? dy : dx) > off) {
|
|
105
|
+
pts.delete(pid(e));
|
|
106
|
+
return;
|
|
107
|
+
} // wrong axis: let the page scroll
|
|
108
|
+
panning = true;
|
|
109
|
+
h.onPan?.({ dx: o.axis === 'y' ? 0 : dx, dy: o.axis === 'x' ? 0 : dy, vx, vy, first: true, last: false, event: e });
|
|
110
|
+
return;
|
|
111
|
+
}
|
|
112
|
+
if (e.cancelable)
|
|
113
|
+
e.preventDefault();
|
|
114
|
+
h.onPan?.({ dx: o.axis === 'y' ? 0 : dx, dy: o.axis === 'x' ? 0 : dy, vx, vy, first: false, last: false, event: e });
|
|
115
|
+
};
|
|
116
|
+
const up = (e) => {
|
|
117
|
+
if (!pts.has(pid(e)))
|
|
118
|
+
return;
|
|
119
|
+
pts.delete(pid(e));
|
|
120
|
+
clearTimeout(press);
|
|
121
|
+
if (pinch) {
|
|
122
|
+
if (pts.size < 2) {
|
|
123
|
+
h.onPinch?.({ scale: pinchScaleNow, ...start, first: false, last: true });
|
|
124
|
+
pinch = null;
|
|
125
|
+
pts.clear();
|
|
126
|
+
}
|
|
127
|
+
return;
|
|
128
|
+
}
|
|
129
|
+
const dx = e.clientX - start.x;
|
|
130
|
+
const dy = e.clientY - start.y;
|
|
131
|
+
if (panning) {
|
|
132
|
+
panning = false;
|
|
133
|
+
if (t(e) - last.t > 80)
|
|
134
|
+
vx = vy = 0; // paused before release
|
|
135
|
+
h.onPan?.({ dx: o.axis === 'y' ? 0 : dx, dy: o.axis === 'x' ? 0 : dy, vx, vy, first: false, last: true, event: e });
|
|
136
|
+
const s = swipeDirection(dx, dy, vx, vy, { distance: o.swipeDistance, velocity: o.swipeVelocity, axis: o.axis });
|
|
137
|
+
if (s)
|
|
138
|
+
h.onSwipe?.(s);
|
|
139
|
+
return;
|
|
140
|
+
}
|
|
141
|
+
if (pressed || e.type === 'pointercancel')
|
|
142
|
+
return;
|
|
143
|
+
const p = { x: e.clientX, y: e.clientY };
|
|
144
|
+
const n = t(e);
|
|
145
|
+
if (h.onDoubleTap && n - lastTap < 300) {
|
|
146
|
+
lastTap = -1e9;
|
|
147
|
+
h.onDoubleTap(p);
|
|
148
|
+
return;
|
|
149
|
+
}
|
|
150
|
+
lastTap = n;
|
|
151
|
+
h.onTap?.(p);
|
|
152
|
+
};
|
|
153
|
+
const wheel = (e) => {
|
|
154
|
+
if (!h.onPinch || o.wheelPinch === false || !e.ctrlKey)
|
|
155
|
+
return;
|
|
156
|
+
e.preventDefault();
|
|
157
|
+
const s = Math.exp(-e.deltaY / 100);
|
|
158
|
+
h.onPinch({ scale: s, x: e.clientX, y: e.clientY, first: true, last: true });
|
|
159
|
+
};
|
|
160
|
+
const opts = { passive: false };
|
|
161
|
+
el.addEventListener('pointerdown', down);
|
|
162
|
+
el.addEventListener('pointermove', move, opts);
|
|
163
|
+
el.addEventListener('pointerup', up);
|
|
164
|
+
el.addEventListener('pointercancel', up);
|
|
165
|
+
el.addEventListener('wheel', wheel, opts);
|
|
166
|
+
if (o.axis && !el.style.touchAction)
|
|
167
|
+
el.style.touchAction = o.axis === 'x' ? 'pan-y' : 'pan-x';
|
|
168
|
+
else if (!o.axis && !el.style.touchAction && (h.onPan || h.onPinch))
|
|
169
|
+
el.style.touchAction = 'none';
|
|
170
|
+
return () => {
|
|
171
|
+
clearTimeout(press);
|
|
172
|
+
el.removeEventListener('pointerdown', down);
|
|
173
|
+
el.removeEventListener('pointermove', move, opts);
|
|
174
|
+
el.removeEventListener('pointerup', up);
|
|
175
|
+
el.removeEventListener('pointercancel', up);
|
|
176
|
+
el.removeEventListener('wheel', wheel, opts);
|
|
177
|
+
};
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
export { gesture as g, pinchScale as p, swipeDirection as s };
|
|
181
|
+
//# sourceMappingURL=core-BIOaYdgN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-BIOaYdgN.js","sources":["../../src/components/gesture/core.ts"],"sourcesContent":["import { clamp } from '../base';\n\nexport interface PanState {\n /** Offset from the gesture start (px). */\n dx: number;\n dy: number;\n /** Velocity (px/s). */\n vx: number;\n vy: number;\n first: boolean;\n last: boolean;\n event: Event;\n}\nexport type SwipeDirection = 'left' | 'right' | 'up' | 'down';\nexport interface SwipeState { direction: SwipeDirection; velocity: number; dx: number; dy: number }\nexport interface PinchState { scale: number; /** Midpoint of the two pointers (client px). */ x: number; y: number; first: boolean; last: boolean }\nexport interface PressState { x: number; y: number }\n\nexport interface GestureHandlers {\n onPan?: (s: PanState) => void;\n onSwipe?: (s: SwipeState) => void;\n onPinch?: (s: PinchState) => void;\n onLongPress?: (s: PressState) => void;\n onTap?: (s: PressState) => void;\n onDoubleTap?: (s: PressState) => void;\n}\n\nexport interface GestureOptions {\n /** Restrict panning to an axis. */\n axis?: 'x' | 'y';\n /** Movement (px) before a pan starts (default 4). */\n threshold?: number;\n /** Minimum distance (px, default 40) and speed (px/s, default 300) for a swipe. */\n swipeDistance?: number;\n swipeVelocity?: number;\n /** Long-press delay (ms, default 500). */\n longPress?: number;\n /** Ctrl/⌘ + wheel (trackpad pinch) counts as pinch (default true). */\n wheelPinch?: boolean;\n}\n\n/** The swipe a pointer release represents, or `null` (pure). */\nexport function swipeDirection(dx: number, dy: number, vx: number, vy: number, o: { distance?: number; velocity?: number; axis?: 'x' | 'y' } = {}): SwipeState | null {\n const dist = o.distance ?? 40;\n const vel = o.velocity ?? 300;\n const horiz = o.axis === 'x' || (o.axis !== 'y' && Math.abs(dx) >= Math.abs(dy));\n const d = horiz ? dx : dy;\n const v = horiz ? vx : vy;\n if (Math.abs(d) < dist && Math.abs(v) < vel * 2) return null;\n if (Math.abs(v) < vel && Math.abs(d) < dist * 3) return null;\n const direction: SwipeDirection = horiz ? (d > 0 ? 'right' : 'left') : d > 0 ? 'down' : 'up';\n return { direction, velocity: Math.abs(v), dx, dy };\n}\n\n/** Scale between two pointer distances, clamped to [min, max] (pure). */\nexport function pinchScale(startDistance: number, distance: number, base = 1, min = 0.5, max = 4): number {\n if (!startDistance) return base;\n return clamp(base * (distance / startDistance), min, max);\n}\n\ntype P = { x: number; y: number };\nconst pid = (e: any): number => (typeof e.pointerId === 'number' ? e.pointerId : 1);\n\n/**\n * One recognizer for pan, swipe, pinch (two pointers or Ctrl + wheel),\n * long-press, tap and double-tap, with velocities ready to hand to a spring\n * (`createSpring().set(target, velocity)`). Works with mouse, touch and pen\n * through Pointer Events. Returns a cleanup function.\n *\n * @example\n * const x = createSpring({ onUpdate: (v) => (card.style.translate = `${v}px`) });\n * gesture(card, {\n * onPan: ({ dx, last, vx }) => (last ? x.set(0, vx) : x.jump(dx)),\n * onSwipe: ({ direction }) => dismiss(direction),\n * }, { axis: 'x' });\n */\nexport function gesture(el: HTMLElement, h: GestureHandlers, o: GestureOptions = {}): () => void {\n const pts = new Map<number, P>();\n let start: P = { x: 0, y: 0 };\n let last: P & { t: number } = { x: 0, y: 0, t: 0 };\n let vx = 0;\n let vy = 0;\n let panning = false;\n let pinch: { d0: number; first: boolean } | null = null;\n let pinchScaleNow = 1;\n let press: ReturnType<typeof setTimeout> | undefined;\n let pressed = false;\n let lastTap = -1e9;\n const th = o.threshold ?? 4;\n const dist = () => {\n const [a, b] = [...pts.values()];\n return Math.hypot(a.x - b.x, a.y - b.y);\n };\n const mid = () => {\n const [a, b] = [...pts.values()];\n return { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };\n };\n const t = (e: Event) => (e.timeStamp || Date.now());\n\n const down = (e: PointerEvent) => {\n pts.set(pid(e), { x: e.clientX, y: e.clientY });\n try { el.setPointerCapture?.(pid(e)); } catch { /* jsdom / synthetic */ }\n if (pts.size === 2 && h.onPinch) {\n clearTimeout(press);\n if (panning) h.onPan?.({ dx: last.x - start.x, dy: last.y - start.y, vx: 0, vy: 0, first: false, last: true, event: e });\n panning = false;\n pinch = { d0: dist(), first: true };\n return;\n }\n if (pts.size > 1) return;\n start = { x: e.clientX, y: e.clientY };\n last = { ...start, t: t(e) };\n vx = vy = 0;\n pressed = false;\n if (h.onLongPress) press = setTimeout(() => { pressed = true; h.onLongPress?.({ x: start.x, y: start.y }); }, o.longPress ?? 500);\n };\n const move = (e: PointerEvent) => {\n if (!pts.has(pid(e))) return;\n pts.set(pid(e), { x: e.clientX, y: e.clientY });\n if (pinch && pts.size >= 2) {\n const m = mid();\n pinchScaleNow = pinchScale(pinch.d0, dist(), 1, 0.05, 20);\n h.onPinch?.({ scale: pinchScaleNow, x: m.x, y: m.y, first: pinch.first, last: false });\n pinch.first = false;\n return;\n }\n const dx = e.clientX - start.x;\n const dy = e.clientY - start.y;\n const dt = Math.max(1, t(e) - last.t) / 1000;\n vx = (e.clientX - last.x) / dt;\n vy = (e.clientY - last.y) / dt;\n last = { x: e.clientX, y: e.clientY, t: t(e) };\n if (!panning) {\n const off = o.axis === 'x' ? Math.abs(dx) : o.axis === 'y' ? Math.abs(dy) : Math.hypot(dx, dy);\n if (off < th) return;\n clearTimeout(press);\n if (o.axis && Math.abs(o.axis === 'x' ? dy : dx) > off) { pts.delete(pid(e)); return; } // wrong axis: let the page scroll\n panning = true;\n h.onPan?.({ dx: o.axis === 'y' ? 0 : dx, dy: o.axis === 'x' ? 0 : dy, vx, vy, first: true, last: false, event: e });\n return;\n }\n if (e.cancelable) e.preventDefault();\n h.onPan?.({ dx: o.axis === 'y' ? 0 : dx, dy: o.axis === 'x' ? 0 : dy, vx, vy, first: false, last: false, event: e });\n };\n const up = (e: PointerEvent) => {\n if (!pts.has(pid(e))) return;\n pts.delete(pid(e));\n clearTimeout(press);\n if (pinch) {\n if (pts.size < 2) {\n h.onPinch?.({ scale: pinchScaleNow, ...start, first: false, last: true });\n pinch = null;\n pts.clear();\n }\n return;\n }\n const dx = e.clientX - start.x;\n const dy = e.clientY - start.y;\n if (panning) {\n panning = false;\n if (t(e) - last.t > 80) vx = vy = 0; // paused before release\n h.onPan?.({ dx: o.axis === 'y' ? 0 : dx, dy: o.axis === 'x' ? 0 : dy, vx, vy, first: false, last: true, event: e });\n const s = swipeDirection(dx, dy, vx, vy, { distance: o.swipeDistance, velocity: o.swipeVelocity, axis: o.axis });\n if (s) h.onSwipe?.(s);\n return;\n }\n if (pressed || e.type === 'pointercancel') return;\n const p = { x: e.clientX, y: e.clientY };\n const n = t(e);\n if (h.onDoubleTap && n - lastTap < 300) { lastTap = -1e9; h.onDoubleTap(p); return; }\n lastTap = n;\n h.onTap?.(p);\n };\n const wheel = (e: WheelEvent) => {\n if (!h.onPinch || o.wheelPinch === false || !e.ctrlKey) return;\n e.preventDefault();\n const s = Math.exp(-e.deltaY / 100);\n h.onPinch({ scale: s, x: e.clientX, y: e.clientY, first: true, last: true });\n };\n const opts: AddEventListenerOptions = { passive: false };\n el.addEventListener('pointerdown', down as EventListener);\n el.addEventListener('pointermove', move as EventListener, opts);\n el.addEventListener('pointerup', up as EventListener);\n el.addEventListener('pointercancel', up as EventListener);\n el.addEventListener('wheel', wheel as EventListener, opts);\n if (o.axis && !el.style.touchAction) el.style.touchAction = o.axis === 'x' ? 'pan-y' : 'pan-x';\n else if (!o.axis && !el.style.touchAction && (h.onPan || h.onPinch)) el.style.touchAction = 'none';\n return () => {\n clearTimeout(press);\n el.removeEventListener('pointerdown', down as EventListener);\n el.removeEventListener('pointermove', move as EventListener, opts);\n el.removeEventListener('pointerup', up as EventListener);\n el.removeEventListener('pointercancel', up as EventListener);\n el.removeEventListener('wheel', wheel as EventListener, opts);\n };\n}\n"],"names":[],"mappings":";;AAyCA;AACM,SAAU,cAAc,CAAC,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,EAAU,EAAE,CAAA,GAAgE,EAAE,EAAA;AAC/I,IAAA,MAAM,IAAI,GAAG,CAAC,CAAC,QAAQ,IAAI,EAAE;AAC7B,IAAA,MAAM,GAAG,GAAG,CAAC,CAAC,QAAQ,IAAI,GAAG;AAC7B,IAAA,MAAM,KAAK,GAAG,CAAC,CAAC,IAAI,KAAK,GAAG,KAAK,CAAC,CAAC,IAAI,KAAK,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,IAAI,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAChF,MAAM,CAAC,GAAG,KAAK,G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E,IAAI,CAAC;AAC/D,IAAA,CAAC;AACH;;;;"}
|
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { p as prefersReducedMotion, k as clamp, q as caf, l as applyFrame, r as raf, m as motionScale, n as now } from './base-Yno7N2eC.js';
|
|
2
|
+
import { resolveDurationToken, resolveEasingToken } from '../components/tokens.js';
|
|
3
|
+
|
|
4
|
+
/** 4.1: whether `scrub()` can use native ScrollTimeline / ViewTimeline here. */
|
|
5
|
+
function supportsNativeScrub(source = 'view') {
|
|
6
|
+
const g = globalThis;
|
|
7
|
+
return typeof g[source === 'scroll' ? 'ScrollTimeline' : 'ViewTimeline'] === 'function' && typeof g.Element?.prototype?.animate === 'function';
|
|
8
|
+
}
|
|
9
|
+
const handle = (stop, native) => Object.assign(stop, { native });
|
|
10
|
+
/** Keyframe presets usable by name in `to()` and `data-tl`. */
|
|
11
|
+
const TIMELINE_PRESETS = {
|
|
12
|
+
fade: [{ opacity: 0 }, { opacity: 1 }],
|
|
13
|
+
'fade-up': [{ opacity: 0, transform: 'translateY(24px)' }, { opacity: 1, transform: 'none' }],
|
|
14
|
+
'fade-down': [{ opacity: 0, transform: 'translateY(-24px)' }, { opacity: 1, transform: 'none' }],
|
|
15
|
+
'fade-left': [{ opacity: 0, transform: 'translateX(24px)' }, { opacity: 1, transform: 'none' }],
|
|
16
|
+
'fade-right': [{ opacity: 0, transform: 'translateX(-24px)' }, { opacity: 1, transform: 'none' }],
|
|
17
|
+
scale: [{ opacity: 0, transform: 'scale(0.85)' }, { opacity: 1, transform: 'none' }],
|
|
18
|
+
blur: [{ opacity: 0, filter: 'blur(12px)' }, { opacity: 1, filter: 'blur(0)' }],
|
|
19
|
+
rotate: [{ opacity: 0, transform: 'rotate(-12deg) scale(0.9)' }, { opacity: 1, transform: 'none' }],
|
|
20
|
+
'clip-up': [{ clipPath: 'inset(100% 0 0 0)' }, { clipPath: 'inset(0 0 0 0)' }],
|
|
21
|
+
'clip-right': [{ clipPath: 'inset(0 100% 0 0)' }, { clipPath: 'inset(0 0 0 0)' }],
|
|
22
|
+
};
|
|
23
|
+
/** Resolve a position against the previous step and labels (pure). */
|
|
24
|
+
function resolvePosition(pos, end, prevStart, labels = {}) {
|
|
25
|
+
if (pos === undefined || pos === '' || pos === '>')
|
|
26
|
+
return end;
|
|
27
|
+
if (typeof pos === 'number')
|
|
28
|
+
return Math.max(0, pos);
|
|
29
|
+
const s = String(pos).trim();
|
|
30
|
+
if (/^-?\d+(\.\d+)?$/.test(s))
|
|
31
|
+
return Math.max(0, Number(s));
|
|
32
|
+
const m = /^(<|>|[A-Za-z_][\w-]*)?\s*(?:([+-])=\s*(\d+(?:\.\d+)?))?$/.exec(s);
|
|
33
|
+
if (!m)
|
|
34
|
+
return end;
|
|
35
|
+
const base = m[1] === '<' ? prevStart : m[1] === '>' || !m[1] ? end : labels[m[1]] ?? end;
|
|
36
|
+
const delta = m[2] ? (m[2] === '-' ? -1 : 1) * Number(m[3]) : 0;
|
|
37
|
+
return Math.max(0, base + delta);
|
|
38
|
+
}
|
|
39
|
+
const toEls = (t) => typeof t === 'string' ? (typeof document === 'undefined' ? [] : Array.from(document.querySelectorAll(t))) : t instanceof Element ? [t] : Array.from(t);
|
|
40
|
+
/**
|
|
41
|
+
* Choreograph animations on one clock: chain, overlap, label, seek, reverse and
|
|
42
|
+
* scrub them with scroll. Built on WAAPI (paused animations driven by one
|
|
43
|
+
* playhead); without WAAPI or under reduced motion it jumps to the end state.
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* const tl = timeline({ defaults: { duration: 500 } })
|
|
47
|
+
* .to('.title', 'fade-up')
|
|
48
|
+
* .label('cards')
|
|
49
|
+
* .to('.card', 'scale', { stagger: 80, at: '-=200' })
|
|
50
|
+
* .to('.cta', [{ opacity: 0 }, { opacity: 1 }], { at: 'cards+=400' });
|
|
51
|
+
* tl.play(); // or tl.scrub(document.querySelector('.hero'))
|
|
52
|
+
*/
|
|
53
|
+
function timeline(options = {}) {
|
|
54
|
+
const d = { duration: 600, easing: 'cubic-bezier(0.22, 1, 0.36, 1)', stagger: 0, ...options.defaults };
|
|
55
|
+
const steps = [];
|
|
56
|
+
const cues = [];
|
|
57
|
+
const labels = {};
|
|
58
|
+
let end = 0;
|
|
59
|
+
let prevStart = 0;
|
|
60
|
+
let t = 0;
|
|
61
|
+
let frame = 0;
|
|
62
|
+
let dir = 1;
|
|
63
|
+
let settle;
|
|
64
|
+
let built = false;
|
|
65
|
+
const total = () => Math.max(end, ...cues.map((c) => c.at), 0);
|
|
66
|
+
const build = () => {
|
|
67
|
+
if (built)
|
|
68
|
+
return;
|
|
69
|
+
built = true;
|
|
70
|
+
for (const s of steps) {
|
|
71
|
+
if (typeof s.el.animate !== 'function') {
|
|
72
|
+
s.anim = null;
|
|
73
|
+
continue;
|
|
74
|
+
}
|
|
75
|
+
s.anim = s.el.animate(s.frames, { duration: s.duration, delay: s.start, easing: s.easing, fill: 'both' });
|
|
76
|
+
s.anim.pause?.();
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
const render = (to, from) => {
|
|
80
|
+
build();
|
|
81
|
+
t = clamp(to, 0, total());
|
|
82
|
+
for (const s of steps) {
|
|
83
|
+
if (s.anim)
|
|
84
|
+
s.anim.currentTime = t;
|
|
85
|
+
else
|
|
86
|
+
applyFrame(s.el, s.frames[t >= s.start ? s.frames.length - 1 : 0]);
|
|
87
|
+
}
|
|
88
|
+
for (const c of cues)
|
|
89
|
+
if ((from < c.at && t >= c.at) || (from > c.at && t <= c.at))
|
|
90
|
+
c.fn();
|
|
91
|
+
options.onUpdate?.(total() ? t / total() : 1);
|
|
92
|
+
};
|
|
93
|
+
const stop = () => {
|
|
94
|
+
if (frame)
|
|
95
|
+
caf(frame);
|
|
96
|
+
frame = 0;
|
|
97
|
+
};
|
|
98
|
+
const run = (direction) => {
|
|
99
|
+
stop();
|
|
100
|
+
settle?.();
|
|
101
|
+
dir = direction;
|
|
102
|
+
const target = dir > 0 ? total() : 0;
|
|
103
|
+
const k = motionScale();
|
|
104
|
+
if (prefersReducedMotion() || k === 0 || !total()) {
|
|
105
|
+
render(target, t);
|
|
106
|
+
options.onComplete?.();
|
|
107
|
+
return Promise.resolve();
|
|
108
|
+
}
|
|
109
|
+
const rate = (options.speed ?? 1) / k;
|
|
110
|
+
return new Promise((resolve) => {
|
|
111
|
+
settle = () => { settle = undefined; resolve(); };
|
|
112
|
+
let last = now();
|
|
113
|
+
const loop = () => {
|
|
114
|
+
const n = now();
|
|
115
|
+
const next = t + (n - last) * rate * dir;
|
|
116
|
+
last = n;
|
|
117
|
+
render(next, t);
|
|
118
|
+
if ((dir > 0 && t >= target) || (dir < 0 && t <= 0)) {
|
|
119
|
+
frame = 0;
|
|
120
|
+
options.onComplete?.();
|
|
121
|
+
settle?.();
|
|
122
|
+
return;
|
|
123
|
+
}
|
|
124
|
+
frame = raf(loop);
|
|
125
|
+
};
|
|
126
|
+
frame = raf(loop);
|
|
127
|
+
});
|
|
128
|
+
};
|
|
129
|
+
const api = {
|
|
130
|
+
get duration() { return total(); },
|
|
131
|
+
get labels() { return { ...labels }; },
|
|
132
|
+
get time() { return t; },
|
|
133
|
+
to(target, frames, o = {}) {
|
|
134
|
+
const kf = typeof frames === 'string' ? TIMELINE_PRESETS[frames] || TIMELINE_PRESETS.fade : frames;
|
|
135
|
+
const start = resolvePosition(o.at, end, prevStart, labels);
|
|
136
|
+
const duration = resolveDurationToken(o.duration ?? d.duration, 600);
|
|
137
|
+
const stagger = o.stagger ?? d.stagger;
|
|
138
|
+
let last = start;
|
|
139
|
+
toEls(target).forEach((el, i) => {
|
|
140
|
+
const s = start + i * stagger;
|
|
141
|
+
steps.push({ el, frames: kf, start: s, duration, easing: resolveEasingToken(o.easing ?? d.easing, 'cubic-bezier(0.22, 1, 0.36, 1)') });
|
|
142
|
+
last = Math.max(last, s + duration);
|
|
143
|
+
});
|
|
144
|
+
prevStart = start;
|
|
145
|
+
end = Math.max(end, last);
|
|
146
|
+
built = false;
|
|
147
|
+
steps.forEach((s) => s.anim?.cancel?.());
|
|
148
|
+
return api;
|
|
149
|
+
},
|
|
150
|
+
label(name, at) {
|
|
151
|
+
labels[name] = resolvePosition(at, end, prevStart, labels);
|
|
152
|
+
return api;
|
|
153
|
+
},
|
|
154
|
+
call(fn, at) {
|
|
155
|
+
cues.push({ fn, at: resolvePosition(at, end, prevStart, labels) });
|
|
156
|
+
return api;
|
|
157
|
+
},
|
|
158
|
+
play(from) {
|
|
159
|
+
if (from !== undefined)
|
|
160
|
+
render(resolvePosition(from, 0, 0, labels), t);
|
|
161
|
+
else if (t >= total())
|
|
162
|
+
render(0, -1);
|
|
163
|
+
return run(1);
|
|
164
|
+
},
|
|
165
|
+
reverse() {
|
|
166
|
+
return run(-1);
|
|
167
|
+
},
|
|
168
|
+
pause() {
|
|
169
|
+
stop();
|
|
170
|
+
return api;
|
|
171
|
+
},
|
|
172
|
+
seek(to) {
|
|
173
|
+
stop();
|
|
174
|
+
render(resolvePosition(to, 0, 0, labels), t);
|
|
175
|
+
return api;
|
|
176
|
+
},
|
|
177
|
+
progress(p) {
|
|
178
|
+
if (p !== undefined)
|
|
179
|
+
api.seek(clamp(p, 0, 1) * total());
|
|
180
|
+
return total() ? t / total() : 0;
|
|
181
|
+
},
|
|
182
|
+
scrub(source, o = {}) {
|
|
183
|
+
stop();
|
|
184
|
+
if (prefersReducedMotion() || typeof window === 'undefined') {
|
|
185
|
+
render(total(), t);
|
|
186
|
+
return handle(() => { }, false);
|
|
187
|
+
}
|
|
188
|
+
const mode = o.source ?? 'view';
|
|
189
|
+
const axis = o.axis ?? 'block';
|
|
190
|
+
const needsJs = !!o.smooth || !!o.offset || cues.length > 0 || !!options.onUpdate || o.engine === 'js';
|
|
191
|
+
if (!needsJs && total() > 0 && supportsNativeScrub(mode) && steps.every((st) => typeof st.el.animate === 'function')) {
|
|
192
|
+
// Native: one scroll-driven animation per step, its slice of the
|
|
193
|
+
// timeline mapped onto the scroll range (`cover` for a view timeline).
|
|
194
|
+
const g = globalThis;
|
|
195
|
+
const tl = mode === 'scroll' ? new g.ScrollTimeline({ source, axis }) : new g.ViewTimeline({ subject: source, axis });
|
|
196
|
+
const T = total();
|
|
197
|
+
steps.forEach((st) => st.anim?.cancel?.());
|
|
198
|
+
built = false;
|
|
199
|
+
const pct = (ms) => `${((ms / T) * 100).toFixed(3)}%`;
|
|
200
|
+
const live = steps.map((st) => {
|
|
201
|
+
const range = mode === 'view' ? { rangeStart: `cover ${pct(st.start)}`, rangeEnd: `cover ${pct(st.start + st.duration)}` } : {};
|
|
202
|
+
const timing = { easing: st.easing, fill: 'both', timeline: tl, ...range };
|
|
203
|
+
if (mode === 'scroll')
|
|
204
|
+
Object.assign(timing, { duration: 'auto', rangeStart: pct(st.start), rangeEnd: pct(st.start + st.duration) });
|
|
205
|
+
return st.el.animate(st.frames, timing);
|
|
206
|
+
});
|
|
207
|
+
return handle(() => {
|
|
208
|
+
live.forEach((a) => a.cancel());
|
|
209
|
+
render(t, t);
|
|
210
|
+
}, true);
|
|
211
|
+
}
|
|
212
|
+
let id = 0;
|
|
213
|
+
let cur = t;
|
|
214
|
+
const scroller = mode === 'scroll' ? source : null;
|
|
215
|
+
const progressNow = () => {
|
|
216
|
+
const x = axis === 'x' || axis === 'inline';
|
|
217
|
+
if (scroller) {
|
|
218
|
+
const max = x ? scroller.scrollWidth - scroller.clientWidth : scroller.scrollHeight - scroller.clientHeight;
|
|
219
|
+
return clamp((x ? scroller.scrollLeft : scroller.scrollTop) / (max || 1), 0, 1);
|
|
220
|
+
}
|
|
221
|
+
const r = source.getBoundingClientRect();
|
|
222
|
+
const vh = (x ? window.innerWidth : window.innerHeight) || 1;
|
|
223
|
+
const start = x ? r.left : r.top;
|
|
224
|
+
const size = x ? r.width : r.height;
|
|
225
|
+
return clamp((vh + (o.offset ?? 0) - start) / (vh + size || 1), 0, 1);
|
|
226
|
+
};
|
|
227
|
+
const update = () => {
|
|
228
|
+
id = 0;
|
|
229
|
+
const goal = progressNow() * total();
|
|
230
|
+
const sm = clamp(o.smooth ?? 0, 0, 0.95);
|
|
231
|
+
cur = sm ? cur + (goal - cur) * (1 - sm) : goal;
|
|
232
|
+
render(cur, t);
|
|
233
|
+
if (sm && Math.abs(goal - cur) > 0.5)
|
|
234
|
+
id = raf(update);
|
|
235
|
+
};
|
|
236
|
+
const onScroll = () => { if (!id)
|
|
237
|
+
id = raf(update); };
|
|
238
|
+
const target = scroller || window;
|
|
239
|
+
target.addEventListener('scroll', onScroll, { passive: true });
|
|
240
|
+
window.addEventListener('resize', onScroll, { passive: true });
|
|
241
|
+
update();
|
|
242
|
+
return handle(() => {
|
|
243
|
+
target.removeEventListener('scroll', onScroll);
|
|
244
|
+
window.removeEventListener('resize', onScroll);
|
|
245
|
+
if (id)
|
|
246
|
+
caf(id);
|
|
247
|
+
}, false);
|
|
248
|
+
},
|
|
249
|
+
cancel() {
|
|
250
|
+
stop();
|
|
251
|
+
settle?.();
|
|
252
|
+
steps.forEach((s) => s.anim?.cancel?.());
|
|
253
|
+
built = false;
|
|
254
|
+
},
|
|
255
|
+
};
|
|
256
|
+
return api;
|
|
257
|
+
}
|
|
258
|
+
|
|
259
|
+
export { TIMELINE_PRESETS as T, resolvePosition as r, supportsNativeScrub as s, timeline as t };
|
|
260
|
+
//# sourceMappingURL=core-CUGCsMsJ.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-CUGCsMsJ.js","sources":["../../src/components/timeline/core.ts"],"sourcesContent":["import { prefersReducedMotion, motionScale, applyFrame, raf, caf, now, clamp } from '../base';\nimport { resolveDurationToken, resolveEasingToken } from '../tokens/index';\n\n/**\n * Where a step starts on a timeline:\n * - a number: absolute time in ms\n * - `'>'` (default): when the previous step ends · `'<'`: when it starts\n * - `'+=200'` / `'-=200'`: after / overlapping the previous end\n * - `'<+=100'`: 100ms after the previous step's start\n * - `'intro'` / `'intro+=150'`: at (or relative to) a label\n */\nexport type TimelinePosition = number | string;\n\nexport interface TimelineStepOptions {\n /** Duration in ms or a motion token name (`'fast'`, `'slow'`…; 4.2). Default: timeline default, 600. */\n duration?: number | string;\n /** CSS easing or a motion token name (`'emphasized'`, `'spring'`…; 4.2). Default `cubic-bezier(0.22, 1, 0.36, 1)`. */\n easing?: string;\n /** Start position, see `TimelinePosition`. */\n at?: TimelinePosition;\n /** ms between targets when the selector matches several elements. */\n stagger?: number;\n}\n\nexport interface TimelineOptions {\n /** Defaults for every step. */\n defaults?: Pick<TimelineStepOptions, 'duration' | 'easing' | 'stagger'>;\n /** Playback rate (1 = normal). */\n speed?: number;\n /** Called after `play()` reaches the end (or the start when reversed). */\n onComplete?: () => void;\n /** Called on every frame with progress 0–1. */\n onUpdate?: (progress: number) => void;\n}\n\nexport interface ScrubOptions {\n /** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts (JS engine only). */\n offset?: number;\n /** Smoothing 0–1 (0 = immediate, default 0). Smoothing needs the JS engine. */\n smooth?: number;\n /**\n * 4.1: which progress source drives the timeline.\n * - `'view'` (default): `source` moving through the viewport (CSS `ViewTimeline`, range `cover`).\n * - `'scroll'`: the scroll position of `source` itself (a scroll container; CSS `ScrollTimeline`).\n */\n source?: 'view' | 'scroll';\n /** 4.1: `'auto'` (default) uses the browser's native scroll-driven animations when available, `'js'` forces the fallback. */\n engine?: 'auto' | 'native' | 'js';\n /** 4.1: scroll axis, `'block'` (default) · `'inline'` · `'x'` · `'y'`. */\n axis?: 'block' | 'inline' | 'x' | 'y';\n}\n\n/** The function `scrub()` returns: call it to stop. `native` tells which engine runs it. */\nexport interface ScrubHandle {\n (): void;\n /** `true` when the browser's ScrollTimeline / ViewTimeline drives it (compositor, no JS per frame). */\n readonly native: boolean;\n}\n\n/** 4.1: whether `scrub()` can use native ScrollTimeline / ViewTimeline here. */\nexport function supportsNativeScrub(source: 'view' | 'scroll' = 'view'): boolean {\n const g = globalThis as any;\n return typeof g[source === 'scroll' ? 'ScrollTimeline' : 'ViewTimeline'] === 'function' && typeof g.Element?.prototype?.animate === 'function';\n}\n\nconst handle = (stop: () => void, native: boolean): ScrubHandle => Object.assign(stop, { native }) as ScrubHandle;\n\nexport interface Timeline {\n /** Total length in ms. */\n readonly duration: number;\n /** Label positions in ms. */\n readonly labels: Readonly<Record<string, number>>;\n /** Current playhead in ms. */\n readonly time: number;\n /** Add a step: animate `target` with keyframes or a preset name (`fade-up`, `scale`…). */\n to(target: string | Element | Element[] | NodeList, frames: Keyframe[] | string, options?: TimelineStepOptions): Timeline;\n /** Name a position (default: the current end). */\n label(name: string, at?: TimelinePosition): Timeline;\n /** Run `fn` when the playhead passes `at`. */\n call(fn: () => void, at?: TimelinePosition): Timeline;\n /** Play forwards from the playhead (from 0 when at the end). Resolves at the end. */\n play(from?: TimelinePosition): Promise<void>;\n /** Play backwards to 0. */\n reverse(): Promise<void>;\n pause(): Timeline;\n /** Jump to a time (ms) or label. */\n seek(to: TimelinePosition): Timeline;\n /** Get or set progress 0–1. */\n progress(p?: number): number;\n /**\n * Tie progress to scroll: `source` moving through the viewport (or, with\n * `{ source: 'scroll' }`, a scroll container's own position). Runs on native\n * ScrollTimeline / ViewTimeline when available (and no `smooth`, `offset`,\n * `call()` cues or `onUpdate` need JS), else on a rAF-throttled listener.\n * Returns a stop function with a `native` flag.\n */\n scrub(source: Element, options?: ScrubOptions): ScrubHandle;\n /** Stop and drop every animation (elements keep their last frame). */\n cancel(): void;\n}\n\n/** Keyframe presets usable by name in `to()` and `data-tl`. */\nexport const TIMELINE_PRESETS: Record<string, Keyframe[]> = {\n fade: [{ opacity: 0 }, { opacity: 1 }],\n 'fade-up': [{ opacity: 0, transform: 'translateY(24px)' }, { opacity: 1, transform: 'none' }],\n 'fade-down': [{ opacity: 0, transform: 'translateY(-24px)' }, { opacity: 1, transform: 'none' }],\n 'fade-left': [{ opacity: 0, transform: 'translateX(24px)' }, { opacity: 1, transform: 'none' }],\n 'fade-right': [{ opacity: 0, transform: 'translateX(-24px)' }, { opacity: 1, transform: 'none' }],\n scale: [{ opacity: 0, transform: 'scale(0.85)' }, { opacity: 1, transform: 'none' }],\n blur: [{ opacity: 0, filter: 'blur(12px)' }, { opacity: 1, filter: 'blur(0)' }],\n rotate: [{ opacity: 0, transform: 'rotate(-12deg) scale(0.9)' }, { opacity: 1, transform: 'none' }],\n 'clip-up': [{ clipPath: 'inset(100% 0 0 0)' }, { clipPath: 'inset(0 0 0 0)' }],\n 'clip-right': [{ clipPath: 'inset(0 100% 0 0)' }, { clipPath: 'inset(0 0 0 0)' }],\n};\n\n/** Resolve a position against the previous step and labels (pure). */\nexport function resolvePosition(\n pos: TimelinePosition | undefined,\n end: number,\n prevStart: number,\n labels: Record<string, number> = {}\n): number {\n if (pos === undefined || pos === '' || pos === '>') return end;\n if (typeof pos === 'number') return Math.max(0, pos);\n const s = String(pos).trim();\n if (/^-?\\d+(\\.\\d+)?$/.test(s)) return Math.max(0, Number(s));\n const m = /^(<|>|[A-Za-z_][\\w-]*)?\\s*(?:([+-])=\\s*(\\d+(?:\\.\\d+)?))?$/.exec(s);\n if (!m) return end;\n const base = m[1] === '<' ? prevStart : m[1] === '>' || !m[1] ? end : labels[m[1]] ?? end;\n const delta = m[2] ? (m[2] === '-' ? -1 : 1) * Number(m[3]) : 0;\n return Math.max(0, base + delta);\n}\n\nconst toEls = (t: string | Element | Element[] | NodeList): Element[] =>\n typeof t === 'string' ? (typeof document === 'undefined' ? [] : Array.from(document.querySelectorAll(t))) : t instanceof Element ? [t] : Array.from(t as ArrayLike<Element>);\n\ninterface Step { el: Element; frames: Keyframe[]; start: number; duration: number; easing: string; anim?: Animation | null }\ninterface Cue { fn: () => void; at: number }\n\n/**\n * Choreograph animations on one clock: chain, overlap, label, seek, reverse and\n * scrub them with scroll. Built on WAAPI (paused animations driven by one\n * playhead); without WAAPI or under reduced motion it jumps to the end state.\n *\n * @example\n * const tl = timeline({ defaults: { duration: 500 } })\n * .to('.title', 'fade-up')\n * .label('cards')\n * .to('.card', 'scale', { stagger: 80, at: '-=200' })\n * .to('.cta', [{ opacity: 0 }, { opacity: 1 }], { at: 'cards+=400' });\n * tl.play(); // or tl.scrub(document.querySelector('.hero'))\n */\nexport function timeline(options: TimelineOptions = {}): Timeline {\n const d = { duration: 600, easing: 'cubic-bezier(0.22, 1, 0.36, 1)', stagger: 0, ...options.defaults };\n const steps: Step[] = [];\n const cues: Cue[] = [];\n const labels: Record<string, number> = {};\n let end = 0;\n let prevStart = 0;\n let t = 0;\n let frame = 0;\n let dir = 1;\n let settle: (() => void) | undefined;\n let built = false;\n\n const total = () => Math.max(end, ...cues.map((c) => c.at), 0);\n const build = () => {\n if (built) return;\n built = true;\n for (const s of steps) {\n if (typeof (s.el as HTMLElement).animate !== 'function') { s.anim = null; continue; }\n s.anim = (s.el as HTMLElement).animate(s.frames, { duration: s.duration, delay: s.start, easing: s.easing, fill: 'both' });\n s.anim.pause?.();\n }\n };\n const render = (to: number, from: number) => {\n build();\n t = clamp(to, 0, total());\n for (const s of steps) {\n if (s.anim) s.anim.currentTime = t;\n else applyFrame(s.el as HTMLElement, s.frames[t >= s.start ? s.frames.length - 1 : 0]);\n }\n for (const c of cues) if ((from < c.at && t >= c.at) || (from > c.at && t <= c.at)) c.fn();\n options.onUpdate?.(total() ? t / total() : 1);\n };\n const stop = () => {\n if (frame) caf(frame);\n frame = 0;\n };\n const run = (direction: number): Promise<void> => {\n stop();\n settle?.();\n dir = direction;\n const target = dir > 0 ? total() : 0;\n const k = motionScale();\n if (prefersReducedMotion() || k === 0 || !total()) {\n render(target, t);\n options.onComplete?.();\n return Promise.resolve();\n }\n const rate = (options.speed ?? 1) / k;\n return new Promise<void>((resolve) => {\n settle = () => { settle = undefined; resolve(); };\n let last = now();\n const loop = () => {\n const n = now();\n const next = t + (n - last) * rate * dir;\n last = n;\n render(next, t);\n if ((dir > 0 && t >= target) || (dir < 0 && t <= 0)) {\n frame = 0;\n options.onComplete?.();\n settle?.();\n return;\n }\n frame = raf(loop);\n };\n frame = raf(loop);\n });\n };\n\n const api: Timeline = {\n get duration() { return total(); },\n get labels() { return { ...labels }; },\n get time() { return t; },\n to(target, frames, o = {}) {\n const kf = typeof frames === 'string' ? TIMELINE_PRESETS[frames] || TIMELINE_PRESETS.fade : frames;\n const start = resolvePosition(o.at, end, prevStart, labels);\n const duration = resolveDurationToken(o.duration ?? d.duration, 600);\n const stagger = o.stagger ?? d.stagger;\n let last = start;\n toEls(target).forEach((el, i) => {\n const s = start + i * stagger;\n steps.push({ el, frames: kf, start: s, duration, easing: resolveEasingToken(o.easing ?? d.easing, 'cubic-bezier(0.22, 1, 0.36, 1)') });\n last = Math.max(last, s + duration);\n });\n prevStart = start;\n end = Math.max(end, last);\n built = false;\n steps.forEach((s) => s.anim?.cancel?.());\n return api;\n },\n label(name, at) {\n labels[name] = resolvePosition(at, end, prevStart, labels);\n return api;\n },\n call(fn, at) {\n cues.push({ fn, at: resolvePosition(at, end, prevStart, labels) });\n return api;\n },\n play(from) {\n if (from !== undefined) render(resolvePosition(from, 0, 0, labels), t);\n else if (t >= total()) render(0, -1);\n return run(1);\n },\n reverse() {\n return run(-1);\n },\n pause() {\n stop();\n return api;\n },\n seek(to) {\n stop();\n render(resolvePosition(to, 0, 0, labels), t);\n return api;\n },\n progress(p) {\n if (p !== undefined) api.seek(clamp(p, 0, 1) * total());\n return total() ? t / total() : 0;\n },\n scrub(source, o = {}) {\n stop();\n if (prefersReducedMotion() || typeof window === 'undefined') {\n render(total(), t);\n return handle(() => {}, false);\n }\n const mode = o.source ?? 'view';\n const axis = o.axis ?? 'block';\n const needsJs = !!o.smooth || !!o.offset || cues.length > 0 || !!options.onUpdate || o.engine === 'js';\n if (!needsJs && total() > 0 && supportsNativeScrub(mode) && steps.every((st) => typeof (st.el as HTMLElement).animate === 'function')) {\n // Native: one scroll-driven animation per step, its slice of the\n // timeline mapped onto the scroll range (`cover` for a view timeline).\n const g = globalThis as any;\n const tl = mode === 'scroll' ? new g.ScrollTimeline({ source, axis }) : new g.ViewTimeline({ subject: source, axis });\n const T = total();\n steps.forEach((st) => st.anim?.cancel?.());\n built = false;\n const pct = (ms: number) => `${((ms / T) * 100).toFixed(3)}%`;\n const live = steps.map((st) => {\n const range = mode === 'view' ? { rangeStart: `cover ${pct(st.start)}`, rangeEnd: `cover ${pct(st.start + st.duration)}` } : {};\n const timing: any = { easing: st.easing, fill: 'both', timeline: tl, ...range };\n if (mode === 'scroll') Object.assign(timing, { duration: 'auto', rangeStart: pct(st.start), rangeEnd: pct(st.start + st.duration) });\n return (st.el as HTMLElement).animate(st.frames, timing);\n });\n return handle(() => {\n live.forEach((a) => a.cancel());\n render(t, t);\n }, true);\n }\n let id = 0;\n let cur = t;\n const scroller = mode === 'scroll' ? (source as HTMLElement) : null;\n const progressNow = () => {\n const x = axis === 'x' || axis === 'inline';\n if (scroller) {\n const max = x ? scroller.scrollWidth - scroller.clientWidth : scroller.scrollHeight - scroller.clientHeight;\n return clamp((x ? scroller.scrollLeft : scroller.scrollTop) / (max || 1), 0, 1);\n }\n const r = source.getBoundingClientRect();\n const vh = (x ? window.innerWidth : window.innerHeight) || 1;\n const start = x ? r.left : r.top;\n const size = x ? r.width : r.height;\n return clamp((vh + (o.offset ?? 0) - start) / (vh + size || 1), 0, 1);\n };\n const update = () => {\n id = 0;\n const goal = progressNow() * total();\n const sm = clamp(o.smooth ?? 0, 0, 0.95);\n cur = sm ? cur + (goal - cur) * (1 - sm) : goal;\n render(cur, t);\n if (sm && Math.abs(goal - cur) > 0.5) id = raf(update);\n };\n const onScroll = () => { if (!id) id = raf(update); };\n const target: EventTarget = scroller || window;\n target.addEventListener('scroll', onScroll, { passive: true });\n window.addEventListener('resize', onScroll, { passive: true });\n update();\n return handle(() => {\n target.removeEventListener('scroll', onScroll);\n window.removeEventListener('resize', onScroll);\n if (id) caf(id);\n }, false);\n },\n cancel() {\n stop();\n settle?.();\n steps.forEach((s) => s.anim?.cancel?.());\n built = false;\n },\n };\n return api;\n}\n"],"names":[],"mappings":";;;AA2DA;AACM,SAAU,mBAAmB,CAAC,MAAA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