motionary 0.0.0-stage → 6.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +803 -0
- package/LICENSE +21 -0
- package/README.md +218 -2
- package/README_ja.md +219 -0
- package/README_zh.md +219 -0
- package/bin/usa-codemod-5.mjs +79 -0
- package/bin/usa-codemod-6.mjs +146 -0
- package/dist/chunks/base-BaQV-2ha.cjs +436 -0
- package/dist/chunks/base-BaQV-2ha.cjs.map +1 -0
- package/dist/chunks/base-C_3cAoRz.js +404 -0
- package/dist/chunks/base-C_3cAoRz.js.map +1 -0
- package/dist/chunks/bind-B_CTL6Qn.js +22 -0
- package/dist/chunks/bind-B_CTL6Qn.js.map +1 -0
- package/dist/chunks/bind-Ui43-n2d.cjs +25 -0
- package/dist/chunks/bind-Ui43-n2d.cjs.map +1 -0
- package/dist/chunks/core-B5T0dhFH.cjs +920 -0
- package/dist/chunks/core-B5T0dhFH.cjs.map +1 -0
- package/dist/chunks/core-BGAyaY6L.cjs +265 -0
- package/dist/chunks/core-BGAyaY6L.cjs.map +1 -0
- package/dist/chunks/core-D7cVumUu.js +909 -0
- package/dist/chunks/core-D7cVumUu.js.map +1 -0
- package/dist/chunks/core-VEBw36QK.js +260 -0
- package/dist/chunks/core-VEBw36QK.js.map +1 -0
- package/dist/chunks/core-ps8uvYuN.js +181 -0
- package/dist/chunks/core-ps8uvYuN.js.map +1 -0
- package/dist/chunks/core-zq17EeCI.cjs +185 -0
- package/dist/chunks/core-zq17EeCI.cjs.map +1 -0
- package/dist/chunks/fx-Bs6IrV4Q.js +109 -0
- package/dist/chunks/fx-Bs6IrV4Q.js.map +1 -0
- package/dist/chunks/fx-lBGVtQO1.cjs +114 -0
- package/dist/chunks/fx-lBGVtQO1.cjs.map +1 -0
- package/dist/chunks/generative-D2YyhaeO.js +336 -0
- package/dist/chunks/generative-D2YyhaeO.js.map +1 -0
- package/dist/chunks/generative-DzIZq-_g.cjs +348 -0
- package/dist/chunks/generative-DzIZq-_g.cjs.map +1 -0
- package/dist/chunks/gpu-Bu7qwugO.js +380 -0
- package/dist/chunks/gpu-Bu7qwugO.js.map +1 -0
- package/dist/chunks/gpu-CenK2l6b.cjs +387 -0
- package/dist/chunks/gpu-CenK2l6b.cjs.map +1 -0
- package/dist/chunks/index-tags-DucKMQr_.js +26 -0
- package/dist/chunks/index-tags-DucKMQr_.js.map +1 -0
- package/dist/chunks/index-tags-wv0R_vkO.cjs +28 -0
- package/dist/chunks/index-tags-wv0R_vkO.cjs.map +1 -0
- package/dist/chunks/presets-BYBVJVeP.js +226 -0
- package/dist/chunks/presets-BYBVJVeP.js.map +1 -0
- package/dist/chunks/presets-CUHys3sK.cjs +233 -0
- package/dist/chunks/presets-CUHys3sK.cjs.map +1 -0
- package/dist/chunks/registry-CKNLQpwd.js +121 -0
- package/dist/chunks/registry-CKNLQpwd.js.map +1 -0
- package/dist/chunks/registry-DehBVRDV.cjs +131 -0
- package/dist/chunks/registry-DehBVRDV.cjs.map +1 -0
- package/dist/chunks/spring-CbvHfVtP.js +219 -0
- package/dist/chunks/spring-CbvHfVtP.js.map +1 -0
- package/dist/chunks/spring-Dgx187Vh.cjs +232 -0
- package/dist/chunks/spring-Dgx187Vh.cjs.map +1 -0
- package/dist/chunks/stagger-CCFyhzSw.cjs +86 -0
- package/dist/chunks/stagger-CCFyhzSw.cjs.map +1 -0
- package/dist/chunks/stagger-DtMKo2SK.js +84 -0
- package/dist/chunks/stagger-DtMKo2SK.js.map +1 -0
- package/dist/chunks/variants-BhjyddG8.cjs +39 -0
- package/dist/chunks/variants-BhjyddG8.cjs.map +1 -0
- package/dist/chunks/variants-DRlKVHvu.js +35 -0
- package/dist/chunks/variants-DRlKVHvu.js.map +1 -0
- package/dist/components/a11y.cjs +276 -0
- package/dist/components/a11y.cjs.map +1 -0
- package/dist/components/a11y.d.cts +131 -0
- package/dist/components/a11y.d.ts +131 -0
- package/dist/components/a11y.js +259 -0
- package/dist/components/a11y.js.map +1 -0
- package/dist/components/angular.cjs +76 -0
- package/dist/components/angular.cjs.map +1 -0
- package/dist/components/angular.d.cts +1734 -0
- package/dist/components/angular.d.ts +1734 -0
- package/dist/components/angular.js +70 -0
- package/dist/components/angular.js.map +1 -0
- package/dist/components/background.cjs +659 -0
- package/dist/components/background.cjs.map +1 -0
- package/dist/components/background.css +9 -0
- package/dist/components/background.d.cts +166 -0
- package/dist/components/background.d.ts +166 -0
- package/dist/components/background.js +647 -0
- package/dist/components/background.js.map +1 -0
- package/dist/components/bridge.cjs +154 -0
- package/dist/components/bridge.cjs.map +1 -0
- package/dist/components/bridge.d.cts +63 -0
- package/dist/components/bridge.d.ts +63 -0
- package/dist/components/bridge.js +147 -0
- package/dist/components/bridge.js.map +1 -0
- package/dist/components/cards.cjs +561 -0
- package/dist/components/cards.cjs.map +1 -0
- package/dist/components/cards.css +6 -0
- package/dist/components/cards.d.cts +115 -0
- package/dist/components/cards.d.ts +115 -0
- package/dist/components/cards.js +554 -0
- package/dist/components/cards.js.map +1 -0
- package/dist/components/click.cjs +877 -0
- package/dist/components/click.cjs.map +1 -0
- package/dist/components/click.css +9 -0
- package/dist/components/click.d.cts +218 -0
- package/dist/components/click.d.ts +218 -0
- package/dist/components/click.js +863 -0
- package/dist/components/click.js.map +1 -0
- package/dist/components/depth.cjs +250 -0
- package/dist/components/depth.cjs.map +1 -0
- package/dist/components/depth.css +3 -0
- package/dist/components/depth.d.cts +86 -0
- package/dist/components/depth.d.ts +86 -0
- package/dist/components/depth.js +242 -0
- package/dist/components/depth.js.map +1 -0
- package/dist/components/effects.cjs +2258 -0
- package/dist/components/effects.cjs.map +1 -0
- package/dist/components/effects.d.cts +545 -0
- package/dist/components/effects.d.ts +545 -0
- package/dist/components/effects.js +2200 -0
- package/dist/components/effects.js.map +1 -0
- package/dist/components/feedback.cjs +442 -0
- package/dist/components/feedback.cjs.map +1 -0
- package/dist/components/feedback.css +7 -0
- package/dist/components/feedback.d.cts +144 -0
- package/dist/components/feedback.d.ts +144 -0
- package/dist/components/feedback.js +433 -0
- package/dist/components/feedback.js.map +1 -0
- package/dist/components/fx-gpu.cjs +12 -0
- package/dist/components/fx-gpu.cjs.map +1 -0
- package/dist/components/fx-gpu.d.cts +63 -0
- package/dist/components/fx-gpu.d.ts +63 -0
- package/dist/components/fx-gpu.js +5 -0
- package/dist/components/fx-gpu.js.map +1 -0
- package/dist/components/fx.cjs +169 -0
- package/dist/components/fx.cjs.map +1 -0
- package/dist/components/fx.css +3 -0
- package/dist/components/fx.d.cts +114 -0
- package/dist/components/fx.d.ts +114 -0
- package/dist/components/fx.js +156 -0
- package/dist/components/fx.js.map +1 -0
- package/dist/components/fx2.cjs +25 -0
- package/dist/components/fx2.cjs.map +1 -0
- package/dist/components/fx2.d.cts +136 -0
- package/dist/components/fx2.d.ts +136 -0
- package/dist/components/fx2.js +17 -0
- package/dist/components/fx2.js.map +1 -0
- package/dist/components/gesture.cjs +209 -0
- package/dist/components/gesture.cjs.map +1 -0
- package/dist/components/gesture.css +3 -0
- package/dist/components/gesture.d.cts +134 -0
- package/dist/components/gesture.d.ts +134 -0
- package/dist/components/gesture.js +203 -0
- package/dist/components/gesture.js.map +1 -0
- package/dist/components/interaction.cjs +424 -0
- package/dist/components/interaction.cjs.map +1 -0
- package/dist/components/interaction.css +8 -0
- package/dist/components/interaction.d.cts +115 -0
- package/dist/components/interaction.d.ts +115 -0
- package/dist/components/interaction.js +416 -0
- package/dist/components/interaction.js.map +1 -0
- package/dist/components/jsx.cjs +3 -0
- package/dist/components/jsx.cjs.map +1 -0
- package/dist/components/jsx.d.cts +53 -0
- package/dist/components/jsx.d.ts +53 -0
- package/dist/components/jsx.js +2 -0
- package/dist/components/jsx.js.map +1 -0
- package/dist/components/layout.cjs +257 -0
- package/dist/components/layout.cjs.map +1 -0
- package/dist/components/layout.css +3 -0
- package/dist/components/layout.d.cts +99 -0
- package/dist/components/layout.d.ts +99 -0
- package/dist/components/layout.js +249 -0
- package/dist/components/layout.js.map +1 -0
- package/dist/components/lazy.cjs +92 -0
- package/dist/components/lazy.cjs.map +1 -0
- package/dist/components/lazy.d.cts +48 -0
- package/dist/components/lazy.d.ts +48 -0
- package/dist/components/lazy.js +87 -0
- package/dist/components/lazy.js.map +1 -0
- package/dist/components/lite.cjs +11095 -0
- package/dist/components/lite.cjs.map +1 -0
- package/dist/components/lite.d.cts +4 -0
- package/dist/components/lite.d.ts +4 -0
- package/dist/components/lite.js +10827 -0
- package/dist/components/lite.js.map +1 -0
- package/dist/components/packs.cjs +192 -0
- package/dist/components/packs.cjs.map +1 -0
- package/dist/components/packs.css +3 -0
- package/dist/components/packs.d.cts +72 -0
- package/dist/components/packs.d.ts +72 -0
- package/dist/components/packs.js +184 -0
- package/dist/components/packs.js.map +1 -0
- package/dist/components/page.cjs +824 -0
- package/dist/components/page.cjs.map +1 -0
- package/dist/components/page.css +11 -0
- package/dist/components/page.d.cts +249 -0
- package/dist/components/page.d.ts +249 -0
- package/dist/components/page.js +799 -0
- package/dist/components/page.js.map +1 -0
- package/dist/components/perf.cjs +120 -0
- package/dist/components/perf.cjs.map +1 -0
- package/dist/components/perf.d.cts +98 -0
- package/dist/components/perf.d.ts +98 -0
- package/dist/components/perf.js +110 -0
- package/dist/components/perf.js.map +1 -0
- package/dist/components/physics.cjs +448 -0
- package/dist/components/physics.cjs.map +1 -0
- package/dist/components/physics.css +5 -0
- package/dist/components/physics.d.cts +189 -0
- package/dist/components/physics.d.ts +189 -0
- package/dist/components/physics.js +430 -0
- package/dist/components/physics.js.map +1 -0
- package/dist/components/react.cjs +96 -0
- package/dist/components/react.cjs.map +1 -0
- package/dist/components/react.d.cts +18 -0
- package/dist/components/react.d.ts +18 -0
- package/dist/components/react.js +91 -0
- package/dist/components/react.js.map +1 -0
- package/dist/components/reveal.cjs +362 -0
- package/dist/components/reveal.cjs.map +1 -0
- package/dist/components/reveal.css +5 -0
- package/dist/components/reveal.d.cts +105 -0
- package/dist/components/reveal.d.ts +105 -0
- package/dist/components/reveal.js +353 -0
- package/dist/components/reveal.js.map +1 -0
- package/dist/components/solid.cjs +86 -0
- package/dist/components/solid.cjs.map +1 -0
- package/dist/components/solid.d.cts +1751 -0
- package/dist/components/solid.d.ts +1751 -0
- package/dist/components/solid.js +82 -0
- package/dist/components/solid.js.map +1 -0
- package/dist/components/svelte.cjs +68 -0
- package/dist/components/svelte.cjs.map +1 -0
- package/dist/components/svelte.d.cts +1733 -0
- package/dist/components/svelte.d.ts +1733 -0
- package/dist/components/svelte.js +64 -0
- package/dist/components/svelte.js.map +1 -0
- package/dist/components/svg.cjs +359 -0
- package/dist/components/svg.cjs.map +1 -0
- package/dist/components/svg.css +3 -0
- package/dist/components/svg.d.cts +113 -0
- package/dist/components/svg.d.ts +113 -0
- package/dist/components/svg.js +347 -0
- package/dist/components/svg.js.map +1 -0
- package/dist/components/text.cjs +968 -0
- package/dist/components/text.cjs.map +1 -0
- package/dist/components/text.css +8 -0
- package/dist/components/text.d.cts +342 -0
- package/dist/components/text.d.ts +342 -0
- package/dist/components/text.js +947 -0
- package/dist/components/text.js.map +1 -0
- package/dist/components/timeline.cjs +109 -0
- package/dist/components/timeline.cjs.map +1 -0
- package/dist/components/timeline.css +3 -0
- package/dist/components/timeline.d.cts +155 -0
- package/dist/components/timeline.d.ts +155 -0
- package/dist/components/timeline.js +103 -0
- package/dist/components/timeline.js.map +1 -0
- package/dist/components/tokens.cjs +226 -0
- package/dist/components/tokens.cjs.map +1 -0
- package/dist/components/tokens.d.cts +74 -0
- package/dist/components/tokens.d.ts +74 -0
- package/dist/components/tokens.js +211 -0
- package/dist/components/tokens.js.map +1 -0
- package/dist/components/transitions.cjs +430 -0
- package/dist/components/transitions.cjs.map +1 -0
- package/dist/components/transitions.css +5 -0
- package/dist/components/transitions.d.cts +126 -0
- package/dist/components/transitions.d.ts +126 -0
- package/dist/components/transitions.js +423 -0
- package/dist/components/transitions.js.map +1 -0
- package/dist/components/ui.cjs +1050 -0
- package/dist/components/ui.cjs.map +1 -0
- package/dist/components/ui.css +14 -0
- package/dist/components/ui.d.cts +224 -0
- package/dist/components/ui.d.ts +224 -0
- package/dist/components/ui.js +1034 -0
- package/dist/components/ui.js.map +1 -0
- package/dist/components/vue.cjs +67 -0
- package/dist/components/vue.cjs.map +1 -0
- package/dist/components/vue.d.cts +1722 -0
- package/dist/components/vue.d.ts +1722 -0
- package/dist/components/vue.js +64 -0
- package/dist/components/vue.js.map +1 -0
- package/dist/components/webgl.cjs +459 -0
- package/dist/components/webgl.cjs.map +1 -0
- package/dist/components/webgl.css +3 -0
- package/dist/components/webgl.d.cts +133 -0
- package/dist/components/webgl.d.ts +133 -0
- package/dist/components/webgl.js +442 -0
- package/dist/components/webgl.js.map +1 -0
- package/dist/components/widgets.cjs +591 -0
- package/dist/components/widgets.cjs.map +1 -0
- package/dist/components/widgets.d.cts +110 -0
- package/dist/components/widgets.d.ts +110 -0
- package/dist/components/widgets.js +581 -0
- package/dist/components/widgets.js.map +1 -0
- package/dist/components.cjs +351 -0
- package/dist/components.cjs.map +1 -0
- package/dist/components.css +75 -0
- package/dist/components.d.cts +2997 -0
- package/dist/components.d.ts +2997 -0
- package/dist/components.js +106 -0
- package/dist/components.js.map +1 -0
- package/dist/components.umd.js +23 -0
- package/dist/components.umd.js.map +1 -0
- package/dist/element.cjs +97 -0
- package/dist/element.cjs.map +1 -0
- package/dist/element.d.cts +215 -0
- package/dist/element.d.ts +215 -0
- package/dist/element.js +95 -0
- package/dist/element.js.map +1 -0
- package/dist/element.umd.js +2 -0
- package/dist/element.umd.js.map +1 -0
- package/dist/index.cjs +149 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +425 -0
- package/dist/index.d.ts +425 -0
- package/dist/index.js +131 -0
- package/dist/index.js.map +1 -0
- package/dist/index.umd.js +15 -0
- package/dist/index.umd.js.map +1 -0
- package/dist/presets/extended.cjs +243 -0
- package/dist/presets/extended.cjs.map +1 -0
- package/dist/presets/extended.d.cts +37 -0
- package/dist/presets/extended.d.ts +37 -0
- package/dist/presets/extended.js +239 -0
- package/dist/presets/extended.js.map +1 -0
- package/dist/presets-extended.umd.js +2 -0
- package/dist/presets-extended.umd.js.map +1 -0
- package/dist/react.cjs +68 -0
- package/dist/react.cjs.map +1 -0
- package/dist/react.d.cts +158 -0
- package/dist/react.d.ts +158 -0
- package/dist/react.js +65 -0
- package/dist/react.js.map +1 -0
- package/dist/solid.cjs +93 -0
- package/dist/solid.cjs.map +1 -0
- package/dist/solid.d.cts +249 -0
- package/dist/solid.d.ts +249 -0
- package/dist/solid.js +89 -0
- package/dist/solid.js.map +1 -0
- package/dist/svelte.cjs +66 -0
- package/dist/svelte.cjs.map +1 -0
- package/dist/svelte.d.cts +243 -0
- package/dist/svelte.d.ts +243 -0
- package/dist/svelte.js +63 -0
- package/dist/svelte.js.map +1 -0
- package/dist/vue.cjs +62 -0
- package/dist/vue.cjs.map +1 -0
- package/dist/vue.d.cts +158 -0
- package/dist/vue.d.ts +158 -0
- package/dist/vue.js +60 -0
- package/dist/vue.js.map +1 -0
- package/dist/widgets.umd.js +2 -0
- package/dist/widgets.umd.js.map +1 -0
- package/docs/API.md +147 -0
- package/docs/ROADMAP.md +14 -0
- package/docs/accessibility.md +60 -0
- package/docs/components.md +564 -0
- package/docs/deprecations.md +30 -0
- package/docs/frameworks-ssr.md +100 -0
- package/docs/hybrid-apps.md +145 -0
- package/docs/images/showcase-detail.png +0 -0
- package/docs/images/showcase-grid.png +0 -0
- package/docs/images/showcase-mobile.png +0 -0
- package/docs/migration-from-aos.md +67 -0
- package/docs/migration-from-gsap-scrolltrigger.md +80 -0
- package/docs/motion-tokens.css +31 -0
- package/docs/motion-tokens.md +46 -0
- package/docs/motion.tokens.json +132 -0
- package/docs/performance.md +24 -0
- package/docs/presets.md +310 -0
- package/docs/upgrading-3.md +21 -0
- package/docs/upgrading-4.md +65 -0
- package/docs/upgrading-5.md +31 -0
- package/docs/upgrading-6.md +32 -0
- package/docs/windows-apps.md +119 -0
- package/package.json +562 -4
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
import { k as clamp } from './base-C_3cAoRz.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-ps8uvYuN.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-ps8uvYuN.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,GAAG,EAAE,GAAG,EAAE;IACzB,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,GAAG,EAAE;AACzB,IAAA,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC;AAAE,QAAA,OAAO,IAAI;AAC5D,IA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AAC,gBAAgB,CAAC,aAAa,EAAE,IAAqB,EAAE,IAAI,CAAC;AAC/D,IAAA,EAAE,CAAC,gBAAgB,CAAC,WAAW,EAAE,EAAmB,CAAC;AACrD,IAAA,EAAE,CAAC,gBAAgB,CAAC,eAAe,EAAE,EAAmB,CAAC;IACzD,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAsB,EAAE,IAAI,CAAC;IAC1D,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW;AAAE,QAAA,EAAE,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC,IAAI,KAAK,GAAG,GAAG,OAAO,GAAG,OAAO;SACzF,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,CAAC;AAAE,QAAA,EAAE,CAAC,KAAK,CAAC,WAAW,GAAG,MAAM;AAClG,IAAA,OAAO,MAAK;QACV,YAAY,CAAC,KAAK,CAAC;AACnB,QAAA,EAAE,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAqB,CAAC;QAC5D,EAAE,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAqB,EAAE,IAAI,CAAC;AAClE,QAAA,EAAE,CAAC,mBAAmB,CAAC,WAAW,EAAE,EAAmB,CAAC;AACxD,QAAA,EAAE,CAAC,mBAAmB,CAAC,eAAe,EAAE,EAAmB,CAAC;QAC5D,EAAE,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAsB,EAAE,IAAI,CAAC;AAC/D,IAAA,CAAC;AACH;;;;"}
|
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var base = require('./base-BaQV-2ha.cjs');
|
|
4
|
+
|
|
5
|
+
/** The swipe a pointer release represents, or `null` (pure). */
|
|
6
|
+
function swipeDirection(dx, dy, vx, vy, o = {}) {
|
|
7
|
+
const dist = o.distance ?? 40;
|
|
8
|
+
const vel = o.velocity ?? 300;
|
|
9
|
+
const horiz = o.axis === 'x' || (o.axis !== 'y' && Math.abs(dx) >= Math.abs(dy));
|
|
10
|
+
const d = horiz ? dx : dy;
|
|
11
|
+
const v = horiz ? vx : vy;
|
|
12
|
+
if (Math.abs(d) < dist && Math.abs(v) < vel * 2)
|
|
13
|
+
return null;
|
|
14
|
+
if (Math.abs(v) < vel && Math.abs(d) < dist * 3)
|
|
15
|
+
return null;
|
|
16
|
+
const direction = horiz ? (d > 0 ? 'right' : 'left') : d > 0 ? 'down' : 'up';
|
|
17
|
+
return { direction, velocity: Math.abs(v), dx, dy };
|
|
18
|
+
}
|
|
19
|
+
/** Scale between two pointer distances, clamped to [min, max] (pure). */
|
|
20
|
+
function pinchScale(startDistance, distance, base$1 = 1, min = 0.5, max = 4) {
|
|
21
|
+
if (!startDistance)
|
|
22
|
+
return base$1;
|
|
23
|
+
return base.clamp(base$1 * (distance / startDistance), min, max);
|
|
24
|
+
}
|
|
25
|
+
const pid = (e) => (typeof e.pointerId === 'number' ? e.pointerId : 1);
|
|
26
|
+
/**
|
|
27
|
+
* One recognizer for pan, swipe, pinch (two pointers or Ctrl + wheel),
|
|
28
|
+
* long-press, tap and double-tap, with velocities ready to hand to a spring
|
|
29
|
+
* (`createSpring().set(target, velocity)`). Works with mouse, touch and pen
|
|
30
|
+
* through Pointer Events. Returns a cleanup function.
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* const x = createSpring({ onUpdate: (v) => (card.style.translate = `${v}px`) });
|
|
34
|
+
* gesture(card, {
|
|
35
|
+
* onPan: ({ dx, last, vx }) => (last ? x.set(0, vx) : x.jump(dx)),
|
|
36
|
+
* onSwipe: ({ direction }) => dismiss(direction),
|
|
37
|
+
* }, { axis: 'x' });
|
|
38
|
+
*/
|
|
39
|
+
function gesture(el, h, o = {}) {
|
|
40
|
+
const pts = new Map();
|
|
41
|
+
let start = { x: 0, y: 0 };
|
|
42
|
+
let last = { x: 0, y: 0, t: 0 };
|
|
43
|
+
let vx = 0;
|
|
44
|
+
let vy = 0;
|
|
45
|
+
let panning = false;
|
|
46
|
+
let pinch = null;
|
|
47
|
+
let pinchScaleNow = 1;
|
|
48
|
+
let press;
|
|
49
|
+
let pressed = false;
|
|
50
|
+
let lastTap = -1e9;
|
|
51
|
+
const th = o.threshold ?? 4;
|
|
52
|
+
const dist = () => {
|
|
53
|
+
const [a, b] = [...pts.values()];
|
|
54
|
+
return Math.hypot(a.x - b.x, a.y - b.y);
|
|
55
|
+
};
|
|
56
|
+
const mid = () => {
|
|
57
|
+
const [a, b] = [...pts.values()];
|
|
58
|
+
return { x: (a.x + b.x) / 2, y: (a.y + b.y) / 2 };
|
|
59
|
+
};
|
|
60
|
+
const t = (e) => (e.timeStamp || Date.now());
|
|
61
|
+
const down = (e) => {
|
|
62
|
+
pts.set(pid(e), { x: e.clientX, y: e.clientY });
|
|
63
|
+
try {
|
|
64
|
+
el.setPointerCapture?.(pid(e));
|
|
65
|
+
}
|
|
66
|
+
catch { /* jsdom / synthetic */ }
|
|
67
|
+
if (pts.size === 2 && h.onPinch) {
|
|
68
|
+
clearTimeout(press);
|
|
69
|
+
if (panning)
|
|
70
|
+
h.onPan?.({ dx: last.x - start.x, dy: last.y - start.y, vx: 0, vy: 0, first: false, last: true, event: e });
|
|
71
|
+
panning = false;
|
|
72
|
+
pinch = { d0: dist(), first: true };
|
|
73
|
+
return;
|
|
74
|
+
}
|
|
75
|
+
if (pts.size > 1)
|
|
76
|
+
return;
|
|
77
|
+
start = { x: e.clientX, y: e.clientY };
|
|
78
|
+
last = { ...start, t: t(e) };
|
|
79
|
+
vx = vy = 0;
|
|
80
|
+
pressed = false;
|
|
81
|
+
if (h.onLongPress)
|
|
82
|
+
press = setTimeout(() => { pressed = true; h.onLongPress?.({ x: start.x, y: start.y }); }, o.longPress ?? 500);
|
|
83
|
+
};
|
|
84
|
+
const move = (e) => {
|
|
85
|
+
if (!pts.has(pid(e)))
|
|
86
|
+
return;
|
|
87
|
+
pts.set(pid(e), { x: e.clientX, y: e.clientY });
|
|
88
|
+
if (pinch && pts.size >= 2) {
|
|
89
|
+
const m = mid();
|
|
90
|
+
pinchScaleNow = pinchScale(pinch.d0, dist(), 1, 0.05, 20);
|
|
91
|
+
h.onPinch?.({ scale: pinchScaleNow, x: m.x, y: m.y, first: pinch.first, last: false });
|
|
92
|
+
pinch.first = false;
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
const dx = e.clientX - start.x;
|
|
96
|
+
const dy = e.clientY - start.y;
|
|
97
|
+
const dt = Math.max(1, t(e) - last.t) / 1000;
|
|
98
|
+
vx = (e.clientX - last.x) / dt;
|
|
99
|
+
vy = (e.clientY - last.y) / dt;
|
|
100
|
+
last = { x: e.clientX, y: e.clientY, t: t(e) };
|
|
101
|
+
if (!panning) {
|
|
102
|
+
const off = o.axis === 'x' ? Math.abs(dx) : o.axis === 'y' ? Math.abs(dy) : Math.hypot(dx, dy);
|
|
103
|
+
if (off < th)
|
|
104
|
+
return;
|
|
105
|
+
clearTimeout(press);
|
|
106
|
+
if (o.axis && Math.abs(o.axis === 'x' ? dy : dx) > off) {
|
|
107
|
+
pts.delete(pid(e));
|
|
108
|
+
return;
|
|
109
|
+
} // wrong axis: let the page scroll
|
|
110
|
+
panning = true;
|
|
111
|
+
h.onPan?.({ dx: o.axis === 'y' ? 0 : dx, dy: o.axis === 'x' ? 0 : dy, vx, vy, first: true, last: false, event: e });
|
|
112
|
+
return;
|
|
113
|
+
}
|
|
114
|
+
if (e.cancelable)
|
|
115
|
+
e.preventDefault();
|
|
116
|
+
h.onPan?.({ dx: o.axis === 'y' ? 0 : dx, dy: o.axis === 'x' ? 0 : dy, vx, vy, first: false, last: false, event: e });
|
|
117
|
+
};
|
|
118
|
+
const up = (e) => {
|
|
119
|
+
if (!pts.has(pid(e)))
|
|
120
|
+
return;
|
|
121
|
+
pts.delete(pid(e));
|
|
122
|
+
clearTimeout(press);
|
|
123
|
+
if (pinch) {
|
|
124
|
+
if (pts.size < 2) {
|
|
125
|
+
h.onPinch?.({ scale: pinchScaleNow, ...start, first: false, last: true });
|
|
126
|
+
pinch = null;
|
|
127
|
+
pts.clear();
|
|
128
|
+
}
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
const dx = e.clientX - start.x;
|
|
132
|
+
const dy = e.clientY - start.y;
|
|
133
|
+
if (panning) {
|
|
134
|
+
panning = false;
|
|
135
|
+
if (t(e) - last.t > 80)
|
|
136
|
+
vx = vy = 0; // paused before release
|
|
137
|
+
h.onPan?.({ dx: o.axis === 'y' ? 0 : dx, dy: o.axis === 'x' ? 0 : dy, vx, vy, first: false, last: true, event: e });
|
|
138
|
+
const s = swipeDirection(dx, dy, vx, vy, { distance: o.swipeDistance, velocity: o.swipeVelocity, axis: o.axis });
|
|
139
|
+
if (s)
|
|
140
|
+
h.onSwipe?.(s);
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
143
|
+
if (pressed || e.type === 'pointercancel')
|
|
144
|
+
return;
|
|
145
|
+
const p = { x: e.clientX, y: e.clientY };
|
|
146
|
+
const n = t(e);
|
|
147
|
+
if (h.onDoubleTap && n - lastTap < 300) {
|
|
148
|
+
lastTap = -1e9;
|
|
149
|
+
h.onDoubleTap(p);
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
lastTap = n;
|
|
153
|
+
h.onTap?.(p);
|
|
154
|
+
};
|
|
155
|
+
const wheel = (e) => {
|
|
156
|
+
if (!h.onPinch || o.wheelPinch === false || !e.ctrlKey)
|
|
157
|
+
return;
|
|
158
|
+
e.preventDefault();
|
|
159
|
+
const s = Math.exp(-e.deltaY / 100);
|
|
160
|
+
h.onPinch({ scale: s, x: e.clientX, y: e.clientY, first: true, last: true });
|
|
161
|
+
};
|
|
162
|
+
const opts = { passive: false };
|
|
163
|
+
el.addEventListener('pointerdown', down);
|
|
164
|
+
el.addEventListener('pointermove', move, opts);
|
|
165
|
+
el.addEventListener('pointerup', up);
|
|
166
|
+
el.addEventListener('pointercancel', up);
|
|
167
|
+
el.addEventListener('wheel', wheel, opts);
|
|
168
|
+
if (o.axis && !el.style.touchAction)
|
|
169
|
+
el.style.touchAction = o.axis === 'x' ? 'pan-y' : 'pan-x';
|
|
170
|
+
else if (!o.axis && !el.style.touchAction && (h.onPan || h.onPinch))
|
|
171
|
+
el.style.touchAction = 'none';
|
|
172
|
+
return () => {
|
|
173
|
+
clearTimeout(press);
|
|
174
|
+
el.removeEventListener('pointerdown', down);
|
|
175
|
+
el.removeEventListener('pointermove', move, opts);
|
|
176
|
+
el.removeEventListener('pointerup', up);
|
|
177
|
+
el.removeEventListener('pointercancel', up);
|
|
178
|
+
el.removeEventListener('wheel', wheel, opts);
|
|
179
|
+
};
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
exports.gesture = gesture;
|
|
183
|
+
exports.pinchScale = pinchScale;
|
|
184
|
+
exports.swipeDirection = swipeDirection;
|
|
185
|
+
//# sourceMappingURL=core-zq17EeCI.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"core-zq17EeCI.cjs","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":["base","clamp"],"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,GAAG,EAAE,GAAG,EAAE;IACzB,MAAM,CAAC,GAAG,KAAK,GAAG,EAAE,GAAG,EAAE;AACzB,IAAA,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,GAAG,CAAC;AAAE,QAAA,OAAO,IAAI;AAC5D,IAAA,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GAAG,GAAG,IAAI,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,GA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AW,EAAE,EAAmB,CAAC;AACrD,IAAA,EAAE,CAAC,gBAAgB,CAAC,eAAe,EAAE,EAAmB,CAAC;IACzD,EAAE,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAsB,EAAE,IAAI,CAAC;IAC1D,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW;AAAE,QAAA,EAAE,CAAC,KAAK,CAAC,WAAW,GAAG,CAAC,CAAC,IAAI,KAAK,GAAG,GAAG,OAAO,GAAG,OAAO;SACzF,IAAI,CAAC,CAAC,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,KAAK,CAAC,CAAC,KAAK,IAAI,CAAC,CAAC,OAAO,CAAC;AAAE,QAAA,EAAE,CAAC,KAAK,CAAC,WAAW,GAAG,MAAM;AAClG,IAAA,OAAO,MAAK;QACV,YAAY,CAAC,KAAK,CAAC;AACnB,QAAA,EAAE,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAqB,CAAC;QAC5D,EAAE,CAAC,mBAAmB,CAAC,aAAa,EAAE,IAAqB,EAAE,IAAI,CAAC;AAClE,QAAA,EAAE,CAAC,mBAAmB,CAAC,WAAW,EAAE,EAAmB,CAAC;AACxD,QAAA,EAAE,CAAC,mBAAmB,CAAC,eAAe,EAAE,EAAmB,CAAC;QAC5D,EAAE,CAAC,mBAAmB,CAAC,OAAO,EAAE,KAAsB,EAAE,IAAI,CAAC;AAC/D,IAAA,CAAC;AACH;;;;;;"}
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
import { p as prefersReducedMotion } from './base-C_3cAoRz.js';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Click-effect helpers (v2.5): `burst()`, `confetti()`, `shake()`, `haptic()`.
|
|
5
|
+
* Particles live in one fixed, pointer-transparent layer and are removed when
|
|
6
|
+
* their animation ends. Under reduced motion particles are skipped and
|
|
7
|
+
* `shake()` only flashes an outline.
|
|
8
|
+
*/
|
|
9
|
+
let layer = null;
|
|
10
|
+
function fxLayer() {
|
|
11
|
+
if (layer && layer.isConnected)
|
|
12
|
+
return layer;
|
|
13
|
+
layer = document.createElement('div');
|
|
14
|
+
layer.className = 'usa-fx-layer';
|
|
15
|
+
layer.setAttribute('aria-hidden', 'true');
|
|
16
|
+
layer.style.cssText = 'position:fixed;inset:0;pointer-events:none;z-index:2147483000;overflow:hidden;contain:strict';
|
|
17
|
+
document.body.appendChild(layer);
|
|
18
|
+
return layer;
|
|
19
|
+
}
|
|
20
|
+
const PALETTE = ['#7c5cff', '#22d3ee', '#f472b6', '#facc15', '#34d399', '#fb923c'];
|
|
21
|
+
const GLYPH = { star: '★', heart: '♥' };
|
|
22
|
+
function particle(x, y, size, color, shape) {
|
|
23
|
+
const p = document.createElement('span');
|
|
24
|
+
const glyph = GLYPH[shape] || (shape !== 'circle' && shape !== 'square' ? shape : '');
|
|
25
|
+
p.style.cssText = `position:absolute;left:${x}px;top:${y}px;width:${size}px;height:${size}px;margin:${-size / 2}px 0 0 ${-size / 2}px;will-change:transform,opacity;` +
|
|
26
|
+
(glyph ? `font-size:${size * 2}px;line-height:${size}px;text-align:center;color:${color}` : `background:${color};border-radius:${shape === 'square' ? '2px' : '50%'}`);
|
|
27
|
+
if (glyph)
|
|
28
|
+
p.textContent = glyph;
|
|
29
|
+
fxLayer().appendChild(p);
|
|
30
|
+
return p;
|
|
31
|
+
}
|
|
32
|
+
const done = (a, el) => {
|
|
33
|
+
if (a)
|
|
34
|
+
a.onfinish = () => el.remove();
|
|
35
|
+
else
|
|
36
|
+
el.remove();
|
|
37
|
+
};
|
|
38
|
+
/** Particles radiating from client point (x, y). Returns the number spawned. */
|
|
39
|
+
function burst(x, y, options = {}) {
|
|
40
|
+
if (typeof document === 'undefined' || prefersReducedMotion())
|
|
41
|
+
return 0;
|
|
42
|
+
const { count = 12, colors = PALETTE, distance = 48, size = 6, shape = 'circle', duration = 600 } = options;
|
|
43
|
+
for (let i = 0; i < count; i++) {
|
|
44
|
+
const angle = (i / count) * Math.PI * 2 + Math.random() * 0.4;
|
|
45
|
+
const d = distance * (0.7 + Math.random() * 0.5);
|
|
46
|
+
const p = particle(x, y, size, colors[i % colors.length], shape);
|
|
47
|
+
const a = typeof p.animate === 'function'
|
|
48
|
+
? p.animate([
|
|
49
|
+
{ transform: 'translate(0,0) scale(1)', opacity: 1 },
|
|
50
|
+
{ transform: `translate(${Math.cos(angle) * d}px, ${Math.sin(angle) * d}px) scale(0.2)`, opacity: 0 },
|
|
51
|
+
], { duration: duration * (0.8 + Math.random() * 0.4), easing: 'cubic-bezier(0.22, 1, 0.36, 1)', fill: 'forwards' })
|
|
52
|
+
: null;
|
|
53
|
+
done(a, p);
|
|
54
|
+
}
|
|
55
|
+
return count;
|
|
56
|
+
}
|
|
57
|
+
/** A confetti cannon (paper pieces with gravity, drift and spin). */
|
|
58
|
+
function confetti(options = {}) {
|
|
59
|
+
if (typeof document === 'undefined' || prefersReducedMotion())
|
|
60
|
+
return 0;
|
|
61
|
+
const W = window.innerWidth || 800;
|
|
62
|
+
const H = window.innerHeight || 600;
|
|
63
|
+
const { x = W / 2, y = H * 0.66, count = 80, spread = 70, velocity = 1, colors = PALETTE, duration = 1600 } = options;
|
|
64
|
+
for (let i = 0; i < count; i++) {
|
|
65
|
+
const angle = ((-90 + (Math.random() - 0.5) * spread) * Math.PI) / 180;
|
|
66
|
+
const speed = (260 + Math.random() * 320) * velocity;
|
|
67
|
+
const vx = Math.cos(angle) * speed;
|
|
68
|
+
const vy = Math.sin(angle) * speed;
|
|
69
|
+
const p = particle(x, y, 6 + Math.random() * 5, colors[i % colors.length], Math.random() > 0.5 ? 'square' : 'circle');
|
|
70
|
+
p.style.height = `${4 + Math.random() * 3}px`;
|
|
71
|
+
const frames = [];
|
|
72
|
+
const steps = 8;
|
|
73
|
+
const T = duration / 1000;
|
|
74
|
+
const spin = (Math.random() - 0.5) * 1440;
|
|
75
|
+
for (let s = 0; s <= steps; s++) {
|
|
76
|
+
const t = (s / steps) * T;
|
|
77
|
+
const g = 900;
|
|
78
|
+
frames.push({
|
|
79
|
+
transform: `translate(${(vx * t * 0.8).toFixed(1)}px, ${(vy * t + 0.5 * g * t * t).toFixed(1)}px) rotate(${((spin * s) / steps).toFixed(0)}deg) rotateX(${s * 120}deg)`,
|
|
80
|
+
opacity: s === steps ? 0 : 1,
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
const a = typeof p.animate === 'function' ? p.animate(frames, { duration: duration * (0.85 + Math.random() * 0.3), easing: 'linear', fill: 'forwards' }) : null;
|
|
84
|
+
done(a, p);
|
|
85
|
+
}
|
|
86
|
+
return count;
|
|
87
|
+
}
|
|
88
|
+
/** Horizontal error shake (`intensity` px, default 8). Reduced motion: a red outline flash. */
|
|
89
|
+
function shake(el, intensity = 8, duration = 480) {
|
|
90
|
+
const t = el;
|
|
91
|
+
if (typeof t.animate !== 'function')
|
|
92
|
+
return null;
|
|
93
|
+
if (prefersReducedMotion())
|
|
94
|
+
return t.animate([{ outline: '2px solid #e5484d' }, { outline: '2px solid transparent' }], { duration: 600 });
|
|
95
|
+
const k = intensity;
|
|
96
|
+
return t.animate([0, -k, k, -k * 0.75, k * 0.75, -k * 0.4, k * 0.4, 0].map((v) => ({ transform: `translateX(${v}px)` })), { duration, easing: 'ease-in-out' });
|
|
97
|
+
}
|
|
98
|
+
/** `navigator.vibrate()` where supported (Android Chrome, some WebViews). Returns whether it ran. */
|
|
99
|
+
function haptic(pattern = 10) {
|
|
100
|
+
try {
|
|
101
|
+
return typeof navigator !== 'undefined' && typeof navigator.vibrate === 'function' ? navigator.vibrate(pattern) : false;
|
|
102
|
+
}
|
|
103
|
+
catch {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
export { burst as b, confetti as c, haptic as h, shake as s };
|
|
109
|
+
//# sourceMappingURL=fx-Bs6IrV4Q.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fx-Bs6IrV4Q.js","sources":["../../src/components/click/fx.ts"],"sourcesContent":["import { prefersReducedMotion, applyFrame } from '../base';\n\n/**\n * Click-effect helpers (v2.5): `burst()`, `confetti()`, `shake()`, `haptic()`.\n * Particles live in one fixed, pointer-transparent layer and are removed when\n * their animation ends. Under reduced motion particles are skipped and\n * `shake()` only flashes an outline.\n */\n\nlet layer: HTMLElement | null = null;\nfunction fxLayer(): HTMLElement {\n if (layer && layer.isConnected) return layer;\n layer = document.createElement('div');\n layer.className = 'usa-fx-layer';\n layer.setAttribute('aria-hidden', 'true');\n layer.style.cssText = 'position:fixed;inset:0;pointer-events:none;z-index:2147483000;overflow:hidden;contain:strict';\n document.body.appendChild(layer);\n return layer;\n}\n\nexport interface BurstOptions {\n /** Number of particles (default 12). */\n count?: number;\n /** Colours to pick from (default: accent palette). */\n colors?: string[];\n /** Travel distance in px (default 48). */\n distance?: number;\n /** Particle size in px (default 6). */\n size?: number;\n /** `circle` (default), `square`, `star`, `heart` or any text / emoji. */\n shape?: 'circle' | 'square' | 'star' | 'heart' | string;\n /** Duration in ms (default 600). */\n duration?: number;\n}\n\nconst PALETTE = ['#7c5cff', '#22d3ee', '#f472b6', '#facc15', '#34d399', '#fb923c'];\nconst GLYPH: Record<string, string> = { star: '★', heart: '♥' };\n\nfunction particle(x: number, y: number, size: number, color: string, shape: string): HTMLElement {\n const p = document.createElement('span');\n const glyph = GLYPH[shape] || (shape !== 'circle' && shape !== 'square' ? shape : '');\n p.style.cssText = `position:absolute;left:${x}px;top:${y}px;width:${size}px;height:${size}px;margin:${-size / 2}px 0 0 ${-size / 2}px;will-change:transform,opacity;` +\n (glyph ? `font-size:${size * 2}px;line-height:${size}px;text-align:center;color:${color}` : `background:${color};border-radius:${shape === 'square' ? '2px' : '50%'}`);\n if (glyph) p.textContent = glyph;\n fxLayer().appendChild(p);\n return p;\n}\n\nconst done = (a: Animation | null, el: Element) => {\n if (a) a.onfinish = () => el.remove();\n else el.remove();\n};\n\n/** Particles radiating from client point (x, y). Returns the number spawned. */\nexport function burst(x: number, y: number, options: BurstOptions = {}): number {\n if (typeof document === 'undefined' || prefersReducedMotion()) return 0;\n const { count = 12, colors = PALETTE, distance = 48, size = 6, shape = 'circle', duration = 600 } = options;\n for (let i = 0; i < count; i++) {\n const angle = (i / count) * Math.PI * 2 + Math.random() * 0.4;\n const d = distance * (0.7 + Math.random() * 0.5);\n const p = particle(x, y, size, colors[i % colors.length], shape);\n const a = typeof p.animate === 'function'\n ? p.animate(\n [\n { transform: 'translate(0,0) scale(1)', opacity: 1 },\n { transform: `translate(${Math.cos(angle) * d}px, ${Math.sin(angle) * d}px) scale(0.2)`, opacity: 0 },\n ],\n { duration: duration * (0.8 + Math.random() * 0.4), easing: 'cubic-bezier(0.22, 1, 0.36, 1)', fill: 'forwards' }\n )\n : null;\n done(a, p);\n }\n return count;\n}\n\nexport interface ConfettiOptions {\n /** Origin in client px (default: centre-bottom third of the viewport). */\n x?: number;\n y?: number;\n /** Pieces (default 80). */\n count?: number;\n /** Spread angle in degrees (default 70). */\n spread?: number;\n /** Launch speed multiplier (default 1). */\n velocity?: number;\n colors?: string[];\n /** Duration in ms (default 1600). */\n duration?: number;\n}\n\n/** A confetti cannon (paper pieces with gravity, drift and spin). */\nexport function confetti(options: ConfettiOptions = {}): number {\n if (typeof document === 'undefined' || prefersReducedMotion()) return 0;\n const W = window.innerWidth || 800;\n const H = window.innerHeight || 600;\n const { x = W / 2, y = H * 0.66, count = 80, spread = 70, velocity = 1, colors = PALETTE, duration = 1600 } = options;\n for (let i = 0; i < count; i++) {\n const angle = ((-90 + (Math.random() - 0.5) * spread) * Math.PI) / 180;\n const speed = (260 + Math.random() * 320) * velocity;\n const vx = Math.cos(angle) * speed;\n const vy = Math.sin(angle) * speed;\n const p = particle(x, y, 6 + Math.random() * 5, colors[i % colors.length], Math.random() > 0.5 ? 'square' : 'circle');\n p.style.height = `${4 + Math.random() * 3}px`;\n const frames: Keyframe[] = [];\n const steps = 8;\n const T = duration / 1000;\n const spin = (Math.random() - 0.5) * 1440;\n for (let s = 0; s <= steps; s++) {\n const t = (s / steps) * T;\n const g = 900;\n frames.push({\n transform: `translate(${(vx * t * 0.8).toFixed(1)}px, ${(vy * t + 0.5 * g * t * t).toFixed(1)}px) rotate(${((spin * s) / steps).toFixed(0)}deg) rotateX(${s * 120}deg)`,\n opacity: s === steps ? 0 : 1,\n });\n }\n const a = typeof p.animate === 'function' ? p.animate(frames, { duration: duration * (0.85 + Math.random() * 0.3), easing: 'linear', fill: 'forwards' }) : null;\n done(a, p);\n }\n return count;\n}\n\n/** Horizontal error shake (`intensity` px, default 8). Reduced motion: a red outline flash. */\nexport function shake(el: Element, intensity = 8, duration = 480): Animation | null {\n const t = el as HTMLElement;\n if (typeof t.animate !== 'function') return null;\n if (prefersReducedMotion()) return t.animate([{ outline: '2px solid #e5484d' }, { outline: '2px solid transparent' }], { duration: 600 });\n const k = intensity;\n return t.animate(\n [0, -k, k, -k * 0.75, k * 0.75, -k * 0.4, k * 0.4, 0].map((v) => ({ transform: `translateX(${v}px)` })),\n { duration, easing: 'ease-in-out' }\n );\n}\n\n/** `navigator.vibrate()` where supported (Android Chrome, some WebViews). Returns whether it ran. */\nexport function haptic(pattern: number | number[] = 10): boolean {\n try {\n return typeof navigator !== 'undefined' && typeof navigator.vibrate === 'function' ? navigator.vibrate(pattern) : false;\n } catch {\n return false;\n }\n}\n\nexport { applyFrame };\n"],"names":[],"mappings":";;AAEA;;;;;AAKG;AAEH,IAAI,KAAK,GAAuB,IAAI;AACpC,SAAS,OAAO,GAAA;AACd,IAAA,IAAI,KAAK,IAAI,KAAK,CAAC,WAAW;AAAE,QAAA,OAAO,KAAK;AAC5C,IAAA,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,KAAK,CAAC;AACrC,IAAA,KAAK,CAAC,SAAS,GAAG,cAAc;AAChC,IAAA,KAAK,CAAC,YAAY,CAAC,aAAa,EAAE,MAAM,CAAC;AACzC,IAAA,KAA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