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,275 @@
|
|
|
1
|
+
import { e as animateWithMotion, i as getMotionSensitivity, p as prefersReducedMotion, x as defineElement } from '../chunks/base-Yno7N2eC.js';
|
|
2
|
+
import { T as TIMELINE_PRESETS } from '../chunks/core-CUGCsMsJ.js';
|
|
3
|
+
import { b as burst, c as confetti, s as shake } from '../chunks/fx-BqDeFywO.js';
|
|
4
|
+
import './tokens.js';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* 5.0 — unified plugin-style effect registration. Every effect (built-in or
|
|
8
|
+
* yours) is a plain object registered once and played the same way:
|
|
9
|
+
* `playEffect(el, name)`, `bindEffect(el, name, { trigger })` or
|
|
10
|
+
* `<usa-fx effect="name" trigger="click">`. Effects get a context that
|
|
11
|
+
* already applies reduced motion, motion sensitivity, intensity and the
|
|
12
|
+
* animation budget.
|
|
13
|
+
*/
|
|
14
|
+
const EFFECT_KINDS = ['enter', 'exit', 'attention', 'click', 'hover', 'card', 'loop', 'page', 'background', 'text', 'cursor', 'scroll'];
|
|
15
|
+
const EFFECT_TRIGGERS = ['click', 'hover', 'enter', 'load', 'loop', 'manual'];
|
|
16
|
+
const registry = new Map();
|
|
17
|
+
/** Register an effect (throws on a duplicate name unless `override`). Returns an unregister function. */
|
|
18
|
+
function registerEffect(def, opts = {}) {
|
|
19
|
+
if (!/^[a-z][a-z0-9-]*$/.test(def.name))
|
|
20
|
+
throw new Error(`[motionary] invalid effect name "${def.name}"`);
|
|
21
|
+
if (!EFFECT_KINDS.includes(def.kind))
|
|
22
|
+
throw new Error(`[motionary] unknown effect kind "${def.kind}"`);
|
|
23
|
+
if (registry.has(def.name) && !opts.override)
|
|
24
|
+
throw new Error(`[motionary] effect "${def.name}" is already registered`);
|
|
25
|
+
registry.set(def.name, def);
|
|
26
|
+
return () => {
|
|
27
|
+
if (registry.get(def.name) === def)
|
|
28
|
+
registry.delete(def.name);
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
/** Register several effects at once (already-registered names are skipped). */
|
|
32
|
+
function registerEffects(defs) {
|
|
33
|
+
for (const d of defs)
|
|
34
|
+
if (!registry.has(d.name))
|
|
35
|
+
registerEffect(d);
|
|
36
|
+
}
|
|
37
|
+
const getEffect = (name) => registry.get(name);
|
|
38
|
+
const hasEffect = (name) => registry.has(name);
|
|
39
|
+
/** Registered effects (optionally of one kind), sorted by name. */
|
|
40
|
+
function listEffects(kind) {
|
|
41
|
+
return Array.from(registry.values())
|
|
42
|
+
.filter((d) => !kind || d.kind === kind)
|
|
43
|
+
.sort((a, b) => a.name.localeCompare(b.name));
|
|
44
|
+
}
|
|
45
|
+
const SKIP_BY_DEFAULT = ['loop', 'background', 'cursor'];
|
|
46
|
+
function context(event) {
|
|
47
|
+
const cleanups = [];
|
|
48
|
+
return {
|
|
49
|
+
reduced: prefersReducedMotion(),
|
|
50
|
+
sensitivity: getMotionSensitivity(),
|
|
51
|
+
event,
|
|
52
|
+
animate: animateWithMotion,
|
|
53
|
+
onCleanup: (fn) => cleanups.push(fn),
|
|
54
|
+
cleanups,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Play a registered effect once on `el`. Resolves when it finishes (or
|
|
59
|
+
* immediately for fire-and-forget effects). Unknown names reject.
|
|
60
|
+
*/
|
|
61
|
+
async function playEffect(el, name, options = {}, event) {
|
|
62
|
+
const def = registry.get(name);
|
|
63
|
+
if (!def)
|
|
64
|
+
throw new Error(`[motionary] unknown effect "${name}" — registered: ${Array.from(registry.keys()).join(', ')}`);
|
|
65
|
+
const ctx = context(event);
|
|
66
|
+
if (ctx.reduced && (def.reduced ?? (SKIP_BY_DEFAULT.includes(def.kind) ? 'skip' : 'run')) === 'skip')
|
|
67
|
+
return;
|
|
68
|
+
const out = def.run(el, { ...(def.defaults || {}), ...options }, ctx);
|
|
69
|
+
if (out && typeof out.finished?.then === 'function')
|
|
70
|
+
await out.finished.catch(() => undefined);
|
|
71
|
+
else if (out && typeof out.then === 'function')
|
|
72
|
+
await out;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Bind an effect to a trigger on `el`: `click`, `hover` (pointerenter / focus),
|
|
76
|
+
* `enter` (scrolls into view; `once` by default), `load` (now), `loop`
|
|
77
|
+
* (starts now, cleanup stops it) or `manual` (nothing). Returns an unbind.
|
|
78
|
+
*/
|
|
79
|
+
function bindEffect(el, name, options = {}) {
|
|
80
|
+
const { trigger = 'click', once, ...opts } = options;
|
|
81
|
+
const def = registry.get(name);
|
|
82
|
+
if (!def)
|
|
83
|
+
throw new Error(`[motionary] unknown effect "${name}"`);
|
|
84
|
+
const offs = [];
|
|
85
|
+
let current = null;
|
|
86
|
+
const fire = (e) => {
|
|
87
|
+
const ctx = context(e);
|
|
88
|
+
if (ctx.reduced && (def.reduced ?? (SKIP_BY_DEFAULT.includes(def.kind) ? 'skip' : 'run')) === 'skip')
|
|
89
|
+
return;
|
|
90
|
+
// A persistent effect (returns a cleanup) replaces its previous run instead of stacking.
|
|
91
|
+
current?.();
|
|
92
|
+
current = null;
|
|
93
|
+
const out = def.run(el, { ...(def.defaults || {}), ...opts }, ctx);
|
|
94
|
+
const stops = [...ctx.cleanups, ...(typeof out === 'function' ? [out] : [])];
|
|
95
|
+
if (stops.length)
|
|
96
|
+
current = () => stops.splice(0).forEach((f) => f());
|
|
97
|
+
};
|
|
98
|
+
offs.push(() => {
|
|
99
|
+
current?.();
|
|
100
|
+
current = null;
|
|
101
|
+
});
|
|
102
|
+
const on = (type, opt) => {
|
|
103
|
+
el.addEventListener(type, fire, opt);
|
|
104
|
+
offs.push(() => el.removeEventListener(type, fire, opt));
|
|
105
|
+
};
|
|
106
|
+
if (trigger === 'click')
|
|
107
|
+
on('click', { once: !!once });
|
|
108
|
+
else if (trigger === 'hover')
|
|
109
|
+
(on('pointerenter'), on('focusin'));
|
|
110
|
+
else if (trigger === 'load' || trigger === 'loop')
|
|
111
|
+
fire();
|
|
112
|
+
else if (trigger === 'enter' && typeof IntersectionObserver !== 'undefined') {
|
|
113
|
+
const io = new IntersectionObserver((entries) => {
|
|
114
|
+
for (const en of entries)
|
|
115
|
+
if (en.isIntersecting) {
|
|
116
|
+
fire();
|
|
117
|
+
if (once !== false)
|
|
118
|
+
io.disconnect();
|
|
119
|
+
}
|
|
120
|
+
}, { threshold: 0.15 });
|
|
121
|
+
io.observe(el);
|
|
122
|
+
offs.push(() => io.disconnect());
|
|
123
|
+
}
|
|
124
|
+
return () => offs.splice(0).reverse().forEach((f) => f());
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
function defineFx(tag = 'usa-fx') {
|
|
128
|
+
return defineElement(tag, (Base) => class UsaFx extends Base {
|
|
129
|
+
static get observedAttributes() {
|
|
130
|
+
return ['effect', 'trigger', 'options'];
|
|
131
|
+
}
|
|
132
|
+
get target() {
|
|
133
|
+
return this.flag('self') ? this : (this.firstElementChild || this);
|
|
134
|
+
}
|
|
135
|
+
opts() {
|
|
136
|
+
try {
|
|
137
|
+
return JSON.parse(this.str('options', '{}')) || {};
|
|
138
|
+
}
|
|
139
|
+
catch {
|
|
140
|
+
return {};
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
play() {
|
|
144
|
+
return playEffect(this.target, this.str('effect', 'pop'), this.opts()).catch(() => undefined);
|
|
145
|
+
}
|
|
146
|
+
mount() {
|
|
147
|
+
if (!this.style.display)
|
|
148
|
+
this.style.display = 'inline-block';
|
|
149
|
+
const name = this.str('effect', 'pop');
|
|
150
|
+
const t = this.str('trigger', 'click');
|
|
151
|
+
try {
|
|
152
|
+
this.onCleanup(bindEffect(this.target, name, { ...this.opts(), trigger: EFFECT_TRIGGERS.includes(t) ? t : 'click', once: this.flag('once') }));
|
|
153
|
+
this.removeAttribute('data-unknown');
|
|
154
|
+
}
|
|
155
|
+
catch {
|
|
156
|
+
this.setAttribute('data-unknown', name); // not registered (yet)
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* 5.0 built-in effects, all registered through `registerEffect()`:
|
|
164
|
+
* every timeline preset as an `enter` effect, attention seekers, and the
|
|
165
|
+
* click effects (burst, confetti, shake, ripple).
|
|
166
|
+
*/
|
|
167
|
+
const enter = Object.entries(TIMELINE_PRESETS).map(([name, frames]) => ({
|
|
168
|
+
name,
|
|
169
|
+
kind: 'enter',
|
|
170
|
+
description: `Entrance: ${name} (same keyframes as the timeline preset).`,
|
|
171
|
+
defaults: { duration: 600, delay: 0, easing: 'cubic-bezier(0.22, 1, 0.36, 1)' },
|
|
172
|
+
run: (el, o, ctx) => ctx.animate(el, ctx.reduced ? [{ opacity: 0 }, { opacity: 1 }] : frames, { duration: o.duration, delay: o.delay, easing: o.easing, fill: 'backwards' }),
|
|
173
|
+
}));
|
|
174
|
+
const A = (name, description, frames, duration = 700, easing = 'ease-in-out') => ({
|
|
175
|
+
name,
|
|
176
|
+
kind: 'attention',
|
|
177
|
+
description,
|
|
178
|
+
defaults: { duration, iterations: 1 },
|
|
179
|
+
run: (el, o, ctx) => (ctx.reduced ? ctx.animate(el, [{ opacity: 1 }, { opacity: 0.6 }, { opacity: 1 }], { duration: 400 }) : ctx.animate(el, frames, { duration: o.duration, easing, iterations: o.iterations })),
|
|
180
|
+
});
|
|
181
|
+
const attention = [
|
|
182
|
+
A('pulse', 'Gentle scale pulse.', [{ transform: 'scale(1)' }, { transform: 'scale(1.08)' }, { transform: 'scale(1)' }], 600),
|
|
183
|
+
A('pop', 'Quick overshoot pop.', [{ transform: 'scale(1)' }, { transform: 'scale(1.18)', offset: 0.4 }, { transform: 'scale(0.96)', offset: 0.7 }, { transform: 'scale(1)' }], 450, 'cubic-bezier(0.34, 1.56, 0.64, 1)'),
|
|
184
|
+
A('jelly', 'Rubbery squash-and-stretch.', [{ transform: 'scale(1,1)' }, { transform: 'scale(1.25,0.75)', offset: 0.3 }, { transform: 'scale(0.75,1.25)', offset: 0.4 }, { transform: 'scale(1.15,0.85)', offset: 0.5 }, { transform: 'scale(0.95,1.05)', offset: 0.65 }, { transform: 'scale(1.05,0.95)', offset: 0.75 }, { transform: 'scale(1,1)' }], 900),
|
|
185
|
+
A('wiggle', 'Playful rotate wiggle.', [{ transform: 'rotate(0)' }, { transform: 'rotate(-8deg)', offset: 0.2 }, { transform: 'rotate(7deg)', offset: 0.4 }, { transform: 'rotate(-5deg)', offset: 0.6 }, { transform: 'rotate(3deg)', offset: 0.8 }, { transform: 'rotate(0)' }], 650),
|
|
186
|
+
A('heartbeat', 'Double-beat heart pulse.', [{ transform: 'scale(1)' }, { transform: 'scale(1.2)', offset: 0.14 }, { transform: 'scale(1)', offset: 0.28 }, { transform: 'scale(1.2)', offset: 0.42 }, { transform: 'scale(1)', offset: 0.7 }], 1100),
|
|
187
|
+
A('bounce', 'Hop up and settle with a squash.', [{ transform: 'translateY(0) scale(1,1)' }, { transform: 'translateY(-22px) scale(0.95,1.05)', offset: 0.35 }, { transform: 'translateY(0) scale(1.08,0.92)', offset: 0.6 }, { transform: 'translateY(-6px) scale(1,1)', offset: 0.8 }, { transform: 'translateY(0) scale(1,1)' }], 800),
|
|
188
|
+
A('flash', 'Two soft flashes (well under 3 per second).', [{ opacity: 1 }, { opacity: 0.25, offset: 0.25 }, { opacity: 1, offset: 0.5 }, { opacity: 0.25, offset: 0.75 }, { opacity: 1 }], 1400),
|
|
189
|
+
A('tada', 'Scale + shake celebration.', [{ transform: 'scale(1) rotate(0)' }, { transform: 'scale(0.9) rotate(-3deg)', offset: 0.1 }, { transform: 'scale(1.1) rotate(3deg)', offset: 0.3 }, { transform: 'scale(1.1) rotate(-3deg)', offset: 0.5 }, { transform: 'scale(1.1) rotate(3deg)', offset: 0.7 }, { transform: 'scale(1) rotate(0)' }], 1000),
|
|
190
|
+
];
|
|
191
|
+
const click = [
|
|
192
|
+
{
|
|
193
|
+
name: 'burst',
|
|
194
|
+
kind: 'click',
|
|
195
|
+
description: 'Particle burst from the click point (or `x` / `y`, or the element center).',
|
|
196
|
+
defaults: { count: 12 },
|
|
197
|
+
run: (el, o, ctx) => {
|
|
198
|
+
if (ctx.reduced)
|
|
199
|
+
return;
|
|
200
|
+
const r = el.getBoundingClientRect();
|
|
201
|
+
const e = ctx.event;
|
|
202
|
+
burst(o.x ?? e?.clientX ?? r.left + r.width / 2, o.y ?? e?.clientY ?? r.top + r.height / 2, o);
|
|
203
|
+
},
|
|
204
|
+
},
|
|
205
|
+
{
|
|
206
|
+
name: 'confetti',
|
|
207
|
+
kind: 'click',
|
|
208
|
+
description: 'Confetti cannon from the element.',
|
|
209
|
+
defaults: { count: 80 },
|
|
210
|
+
run: (el, o, ctx) => {
|
|
211
|
+
if (ctx.reduced)
|
|
212
|
+
return;
|
|
213
|
+
const r = el.getBoundingClientRect();
|
|
214
|
+
confetti({ x: r.left + r.width / 2, y: r.top + r.height / 2, ...o });
|
|
215
|
+
},
|
|
216
|
+
},
|
|
217
|
+
{
|
|
218
|
+
name: 'shake',
|
|
219
|
+
kind: 'attention',
|
|
220
|
+
description: 'Horizontal "no" shake (errors, wrong password).',
|
|
221
|
+
defaults: { intensity: 8, duration: 480 },
|
|
222
|
+
run: (el, o, ctx) => (ctx.reduced ? ctx.animate(el, [{ opacity: 1 }, { opacity: 0.5 }, { opacity: 1 }], { duration: 300 }) : shake(el, o.intensity, o.duration)),
|
|
223
|
+
},
|
|
224
|
+
{
|
|
225
|
+
name: 'ripple',
|
|
226
|
+
kind: 'click',
|
|
227
|
+
description: 'Material-style ink ripple from the pointer.',
|
|
228
|
+
defaults: { color: 'currentColor', duration: 600 },
|
|
229
|
+
run: (el, o, ctx) => {
|
|
230
|
+
var _a;
|
|
231
|
+
if (ctx.reduced)
|
|
232
|
+
return;
|
|
233
|
+
const r = el.getBoundingClientRect();
|
|
234
|
+
const e = ctx.event;
|
|
235
|
+
const d = Math.hypot(r.width, r.height) * 2;
|
|
236
|
+
const dot = document.createElement('span');
|
|
237
|
+
dot.setAttribute('aria-hidden', 'true');
|
|
238
|
+
Object.assign(dot.style, { position: 'absolute', left: `${(e?.clientX ?? r.left + r.width / 2) - r.left - d / 2}px`, top: `${(e?.clientY ?? r.top + r.height / 2) - r.top - d / 2}px`, width: `${d}px`, height: `${d}px`, borderRadius: '50%', background: o.color, opacity: '0.25', pointerEvents: 'none' });
|
|
239
|
+
if (getComputedStyle(el).position === 'static')
|
|
240
|
+
el.style.position = 'relative';
|
|
241
|
+
(_a = el.style).overflow || (_a.overflow = 'hidden');
|
|
242
|
+
el.appendChild(dot);
|
|
243
|
+
const a = ctx.animate(dot, [{ transform: 'scale(0)', opacity: 0.3 }, { transform: 'scale(1)', opacity: 0 }], { duration: o.duration, easing: 'ease-out' });
|
|
244
|
+
const done = () => dot.remove();
|
|
245
|
+
if (a)
|
|
246
|
+
a.finished.then(done, done);
|
|
247
|
+
else
|
|
248
|
+
done();
|
|
249
|
+
return a;
|
|
250
|
+
},
|
|
251
|
+
},
|
|
252
|
+
];
|
|
253
|
+
/** Every built-in 5.0 effect definition. */
|
|
254
|
+
const BUILTIN_EFFECTS = [...enter, ...attention, ...click];
|
|
255
|
+
|
|
256
|
+
/**
|
|
257
|
+
* motionary/components/fx — unified plugin-style effects (5.0).
|
|
258
|
+
* `registerEffect({ name, kind, run })`, `playEffect(el, name)`,
|
|
259
|
+
* `bindEffect(el, name, { trigger })`, `<usa-fx effect trigger>`. Built-ins:
|
|
260
|
+
* every timeline preset (`enter`), `pulse` · `pop` · `jelly` · `wiggle` ·
|
|
261
|
+
* `heartbeat` · `bounce` · `flash` · `tada` · `shake` (attention),
|
|
262
|
+
* `burst` · `confetti` · `ripple` (click). More packs: `motionary/components/effects`.
|
|
263
|
+
*/
|
|
264
|
+
/** Register the built-in effects (idempotent; `defineFxComponents()` calls it). */
|
|
265
|
+
function registerBuiltinEffects() {
|
|
266
|
+
registerEffects(BUILTIN_EFFECTS);
|
|
267
|
+
}
|
|
268
|
+
/** Register every component of this category under its default tag (+ the built-in effects). */
|
|
269
|
+
function defineFxComponents() {
|
|
270
|
+
registerBuiltinEffects();
|
|
271
|
+
defineFx();
|
|
272
|
+
}
|
|
273
|
+
|
|
274
|
+
export { BUILTIN_EFFECTS, EFFECT_KINDS, EFFECT_TRIGGERS, bindEffect, defineFx, defineFxComponents, getEffect, hasEffect, listEffects, playEffect, registerBuiltinEffects, registerEffect, registerEffects };
|
|
275
|
+
//# sourceMappingURL=fx.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fx.js","sources":["../../src/components/fx/registry.ts","../../src/components/fx/fx-el.ts","../../src/components/fx/builtins.ts","../../src/components/fx/index.ts"],"sourcesContent":["/**\n * 5.0 — unified plugin-style effect registration. Every effect (built-in or\n * yours) is a plain object registered once and played the same way:\n * `playEffect(el, name)`, `bindEffect(el, name, { trigger })` or\n * `<usa-fx effect=\"name\" trigger=\"click\">`. Effects get a context that\n * already applies reduced motion, motion sensitivity, intensity and the\n * animation budget.\n */\nimport { animateWithMotion, prefersReducedMotion, getMotionSensitivity, type MotionSensitivity, type Cleanup } from '../base';\n\nexport const EFFECT_KINDS = ['enter', 'exit', 'attention', 'click', 'hover', 'card', 'loop', 'page', 'background', 'text', 'cursor', 'scroll'] as const;\nexport type EffectKind = (typeof EFFECT_KINDS)[number];\n\nexport const EFFECT_TRIGGERS = ['click', 'hover', 'enter', 'load', 'loop', 'manual'] as const;\nexport type EffectTrigger = (typeof EFFECT_TRIGGERS)[number];\n\nexport interface EffectContext {\n /** Reduced motion applies (OS setting, `minimal` / `static` sensitivity). */\n readonly reduced: boolean;\n readonly sensitivity: MotionSensitivity;\n /** The triggering event (pointer position for click effects), if any. */\n readonly event?: Event;\n /** `el.animate()` with the library's motion rules (may return `null`). */\n animate(el: Element, keyframes: Keyframe[], options: KeyframeAnimationOptions): Animation | null;\n /** Register teardown for long-running effects (loops, listeners). */\n onCleanup(fn: Cleanup): void;\n}\n\nexport interface EffectDefinition<O extends Record<string, unknown> = Record<string, any>> {\n /** Unique, kebab-case. */\n name: string;\n kind: EffectKind;\n /** One line for docs and the gallery. */\n description?: string;\n /** Option defaults (merged under the caller's options). */\n defaults?: Partial<O>;\n /**\n * Under reduced motion: `'skip'` (do nothing — default for loop, background\n * and cursor effects) or `'run'` (run with `ctx.reduced === true`, the\n * effect degrades itself — default for everything else).\n */\n reduced?: 'skip' | 'run';\n /** Play the effect. Return an Animation / Promise to be awaited, or a cleanup. */\n run(el: HTMLElement, options: O, ctx: EffectContext): void | Cleanup | Animation | null | Promise<unknown>;\n}\n\nconst registry = new Map<string, EffectDefinition>();\n\n/** Register an effect (throws on a duplicate name unless `override`). Returns an unregister function. */\nexport function registerEffect<O extends Record<string, unknown>>(def: EffectDefinition<O>, opts: { override?: boolean } = {}): () => void {\n if (!/^[a-z][a-z0-9-]*$/.test(def.name)) throw new Error(`[motionary] invalid effect name \"${def.name}\"`);\n if (!EFFECT_KINDS.includes(def.kind)) throw new Error(`[motionary] unknown effect kind \"${def.kind}\"`);\n if (registry.has(def.name) && !opts.override) throw new Error(`[motionary] effect \"${def.name}\" is already registered`);\n registry.set(def.name, def as unknown as EffectDefinition);\n return () => {\n if (registry.get(def.name) === (def as unknown)) registry.delete(def.name);\n };\n}\n\n/** Register several effects at once (already-registered names are skipped). */\nexport function registerEffects(defs: EffectDefinition<any>[]): void {\n for (const d of defs) if (!registry.has(d.name)) registerEffect(d);\n}\n\nexport const getEffect = (name: string): EffectDefinition | undefined => registry.get(name);\nexport const hasEffect = (name: string): boolean => registry.has(name);\n/** Registered effects (optionally of one kind), sorted by name. */\nexport function listEffects(kind?: EffectKind): EffectDefinition[] {\n return Array.from(registry.values())\n .filter((d) => !kind || d.kind === kind)\n .sort((a, b) => a.name.localeCompare(b.name));\n}\n\nconst SKIP_BY_DEFAULT: EffectKind[] = ['loop', 'background', 'cursor'];\n\nfunction context(event?: Event): EffectContext & { cleanups: Cleanup[] } {\n const cleanups: Cleanup[] = [];\n return {\n reduced: prefersReducedMotion(),\n sensitivity: getMotionSensitivity(),\n event,\n animate: animateWithMotion,\n onCleanup: (fn) => cleanups.push(fn),\n cleanups,\n };\n}\n\n/**\n * Play a registered effect once on `el`. Resolves when it finishes (or\n * immediately for fire-and-forget effects). Unknown names reject.\n */\nexport async function playEffect(el: HTMLElement, name: string, options: Record<string, unknown> = {}, event?: Event): Promise<void> {\n const def = registry.get(name);\n if (!def) throw new Error(`[motionary] unknown effect \"${name}\" — registered: ${Array.from(registry.keys()).join(', ')}`);\n const ctx = context(event);\n if (ctx.reduced && (def.reduced ?? (SKIP_BY_DEFAULT.includes(def.kind) ? 'skip' : 'run')) === 'skip') return;\n const out = def.run(el, { ...(def.defaults || {}), ...options }, ctx);\n if (out && typeof (out as Animation).finished?.then === 'function') await (out as Animation).finished.catch(() => undefined);\n else if (out && typeof (out as Promise<unknown>).then === 'function') await out;\n}\n\n/**\n * Bind an effect to a trigger on `el`: `click`, `hover` (pointerenter / focus),\n * `enter` (scrolls into view; `once` by default), `load` (now), `loop`\n * (starts now, cleanup stops it) or `manual` (nothing). Returns an unbind.\n */\nexport function bindEffect(el: HTMLElement, name: string, options: Record<string, unknown> & { trigger?: EffectTrigger; once?: boolean } = {}): Cleanup {\n const { trigger = 'click', once, ...opts } = options;\n const def = registry.get(name);\n if (!def) throw new Error(`[motionary] unknown effect \"${name}\"`);\n const offs: Cleanup[] = [];\n let current: Cleanup | null = null;\n const fire = (e?: Event) => {\n const ctx = context(e);\n if (ctx.reduced && (def.reduced ?? (SKIP_BY_DEFAULT.includes(def.kind) ? 'skip' : 'run')) === 'skip') return;\n // A persistent effect (returns a cleanup) replaces its previous run instead of stacking.\n current?.();\n current = null;\n const out = def.run(el, { ...(def.defaults || {}), ...opts }, ctx);\n const stops = [...ctx.cleanups, ...(typeof out === 'function' ? [out as Cleanup] : [])];\n if (stops.length) current = () => stops.splice(0).forEach((f) => f());\n };\n offs.push(() => {\n current?.();\n current = null;\n });\n const on = (type: string, opt?: AddEventListenerOptions) => {\n el.addEventListener(type, fire, opt);\n offs.push(() => el.removeEventListener(type, fire, opt));\n };\n if (trigger === 'click') on('click', { once: !!once });\n else if (trigger === 'hover') (on('pointerenter'), on('focusin'));\n else if (trigger === 'load' || trigger === 'loop') fire();\n else if (trigger === 'enter' && typeof IntersectionObserver !== 'undefined') {\n const io = new IntersectionObserver((entries) => {\n for (const en of entries)\n if (en.isIntersecting) {\n fire();\n if (once !== false) io.disconnect();\n }\n }, { threshold: 0.15 });\n io.observe(el);\n offs.push(() => io.disconnect());\n }\n return () => offs.splice(0).reverse().forEach((f) => f());\n}\n","import { defineElement, type UsaElement } from '../base';\nimport { bindEffect, playEffect, EFFECT_TRIGGERS, type EffectTrigger } from './registry';\n\n/**\n * `<usa-fx effect=\"pop\" trigger=\"click\">` — plays any registered effect\n * (`registerEffect()`) on its first element child (or itself with `self`).\n * `trigger`: `click` (default) · `hover` · `enter` · `load` · `loop` · `manual`;\n * `options` (JSON) is passed to the effect; `once`. Method `play()`.\n */\nexport interface UsaFxElement extends UsaElement {\n readonly target: HTMLElement;\n play(): Promise<void>;\n}\n\nexport function defineFx(tag = 'usa-fx'): CustomElementConstructor | undefined {\n return defineElement(tag, (Base) =>\n class UsaFx extends Base {\n static get observedAttributes(): string[] {\n return ['effect', 'trigger', 'options'];\n }\n get target(): HTMLElement {\n return this.flag('self') ? this : ((this.firstElementChild as HTMLElement) || this);\n }\n private opts(): Record<string, unknown> {\n try {\n return JSON.parse(this.str('options', '{}')) || {};\n } catch {\n return {};\n }\n }\n play(): Promise<void> {\n return playEffect(this.target, this.str('effect', 'pop'), this.opts()).catch(() => undefined);\n }\n mount(): void {\n if (!this.style.display) this.style.display = 'inline-block';\n const name = this.str('effect', 'pop');\n const t = this.str('trigger', 'click') as EffectTrigger;\n try {\n this.onCleanup(bindEffect(this.target, name, { ...this.opts(), trigger: EFFECT_TRIGGERS.includes(t) ? t : 'click', once: this.flag('once') }));\n this.removeAttribute('data-unknown');\n } catch {\n this.setAttribute('data-unknown', name); // not registered (yet)\n }\n }\n }\n );\n}\n","/**\n * 5.0 built-in effects, all registered through `registerEffect()`:\n * every timeline preset as an `enter` effect, attention seekers, and the\n * click effects (burst, confetti, shake, ripple).\n */\nimport { TIMELINE_PRESETS } from '../timeline/core';\nimport { burst, confetti, shake } from '../click/fx';\nimport type { EffectDefinition } from './registry';\n\nconst enter: EffectDefinition[] = Object.entries(TIMELINE_PRESETS).map(([name, frames]) => ({\n name,\n kind: 'enter' as const,\n description: `Entrance: ${name} (same keyframes as the timeline preset).`,\n defaults: { duration: 600, delay: 0, easing: 'cubic-bezier(0.22, 1, 0.36, 1)' },\n run: (el: HTMLElement, o: any, ctx) => ctx.animate(el, ctx.reduced ? [{ opacity: 0 }, { opacity: 1 }] : frames, { duration: o.duration, delay: o.delay, easing: o.easing, fill: 'backwards' }),\n}));\n\nconst A = (name: string, description: string, frames: Keyframe[], duration = 700, easing = 'ease-in-out'): EffectDefinition => ({\n name,\n kind: 'attention',\n description,\n defaults: { duration, iterations: 1 },\n run: (el, o: any, ctx) => (ctx.reduced ? ctx.animate(el, [{ opacity: 1 }, { opacity: 0.6 }, { opacity: 1 }], { duration: 400 }) : ctx.animate(el, frames, { duration: o.duration, easing, iterations: o.iterations })),\n});\n\nconst attention: EffectDefinition[] = [\n A('pulse', 'Gentle scale pulse.', [{ transform: 'scale(1)' }, { transform: 'scale(1.08)' }, { transform: 'scale(1)' }], 600),\n A('pop', 'Quick overshoot pop.', [{ transform: 'scale(1)' }, { transform: 'scale(1.18)', offset: 0.4 }, { transform: 'scale(0.96)', offset: 0.7 }, { transform: 'scale(1)' }], 450, 'cubic-bezier(0.34, 1.56, 0.64, 1)'),\n A('jelly', 'Rubbery squash-and-stretch.', [{ transform: 'scale(1,1)' }, { transform: 'scale(1.25,0.75)', offset: 0.3 }, { transform: 'scale(0.75,1.25)', offset: 0.4 }, { transform: 'scale(1.15,0.85)', offset: 0.5 }, { transform: 'scale(0.95,1.05)', offset: 0.65 }, { transform: 'scale(1.05,0.95)', offset: 0.75 }, { transform: 'scale(1,1)' }], 900),\n A('wiggle', 'Playful rotate wiggle.', [{ transform: 'rotate(0)' }, { transform: 'rotate(-8deg)', offset: 0.2 }, { transform: 'rotate(7deg)', offset: 0.4 }, { transform: 'rotate(-5deg)', offset: 0.6 }, { transform: 'rotate(3deg)', offset: 0.8 }, { transform: 'rotate(0)' }], 650),\n A('heartbeat', 'Double-beat heart pulse.', [{ transform: 'scale(1)' }, { transform: 'scale(1.2)', offset: 0.14 }, { transform: 'scale(1)', offset: 0.28 }, { transform: 'scale(1.2)', offset: 0.42 }, { transform: 'scale(1)', offset: 0.7 }], 1100),\n A('bounce', 'Hop up and settle with a squash.', [{ transform: 'translateY(0) scale(1,1)' }, { transform: 'translateY(-22px) scale(0.95,1.05)', offset: 0.35 }, { transform: 'translateY(0) scale(1.08,0.92)', offset: 0.6 }, { transform: 'translateY(-6px) scale(1,1)', offset: 0.8 }, { transform: 'translateY(0) scale(1,1)' }], 800),\n A('flash', 'Two soft flashes (well under 3 per second).', [{ opacity: 1 }, { opacity: 0.25, offset: 0.25 }, { opacity: 1, offset: 0.5 }, { opacity: 0.25, offset: 0.75 }, { opacity: 1 }], 1400),\n A('tada', 'Scale + shake celebration.', [{ transform: 'scale(1) rotate(0)' }, { transform: 'scale(0.9) rotate(-3deg)', offset: 0.1 }, { transform: 'scale(1.1) rotate(3deg)', offset: 0.3 }, { transform: 'scale(1.1) rotate(-3deg)', offset: 0.5 }, { transform: 'scale(1.1) rotate(3deg)', offset: 0.7 }, { transform: 'scale(1) rotate(0)' }], 1000),\n];\n\nconst click: EffectDefinition[] = [\n {\n name: 'burst',\n kind: 'click',\n description: 'Particle burst from the click point (or `x` / `y`, or the element center).',\n defaults: { count: 12 },\n run: (el, o: any, ctx) => {\n if (ctx.reduced) return;\n const r = el.getBoundingClientRect();\n const e = ctx.event as PointerEvent | undefined;\n burst(o.x ?? e?.clientX ?? r.left + r.width / 2, o.y ?? e?.clientY ?? r.top + r.height / 2, o);\n },\n },\n {\n name: 'confetti',\n kind: 'click',\n description: 'Confetti cannon from the element.',\n defaults: { count: 80 },\n run: (el, o: any, ctx) => {\n if (ctx.reduced) return;\n const r = el.getBoundingClientRect();\n confetti({ x: r.left + r.width / 2, y: r.top + r.height / 2, ...o });\n },\n },\n {\n name: 'shake',\n kind: 'attention',\n description: 'Horizontal \"no\" shake (errors, wrong password).',\n defaults: { intensity: 8, duration: 480 },\n run: (el, o: any, ctx) => (ctx.reduced ? ctx.animate(el, [{ opacity: 1 }, { opacity: 0.5 }, { opacity: 1 }], { duration: 300 }) : shake(el, o.intensity, o.duration)),\n },\n {\n name: 'ripple',\n kind: 'click',\n description: 'Material-style ink ripple from the pointer.',\n defaults: { color: 'currentColor', duration: 600 },\n run: (el, o: any, ctx) => {\n if (ctx.reduced) return;\n const r = el.getBoundingClientRect();\n const e = ctx.event as PointerEvent | undefined;\n const d = Math.hypot(r.width, r.height) * 2;\n const dot = document.createElement('span');\n dot.setAttribute('aria-hidden', 'true');\n Object.assign(dot.style, { position: 'absolute', left: `${(e?.clientX ?? r.left + r.width / 2) - r.left - d / 2}px`, top: `${(e?.clientY ?? r.top + r.height / 2) - r.top - d / 2}px`, width: `${d}px`, height: `${d}px`, borderRadius: '50%', background: o.color, opacity: '0.25', pointerEvents: 'none' });\n if (getComputedStyle(el).position === 'static') el.style.position = 'relative';\n el.style.overflow ||= 'hidden';\n el.appendChild(dot);\n const a = ctx.animate(dot, [{ transform: 'scale(0)', opacity: 0.3 }, { transform: 'scale(1)', opacity: 0 }], { duration: o.duration, easing: 'ease-out' });\n const done = () => dot.remove();\n if (a) a.finished.then(done, done);\n else done();\n return a;\n },\n },\n];\n\n/** Every built-in 5.0 effect definition. */\nexport const BUILTIN_EFFECTS: EffectDefinition[] = [...enter, ...attention, ...click];\n","/**\n * motionary/components/fx — unified plugin-style effects (5.0).\n * `registerEffect({ name, kind, run })`, `playEffect(el, name)`,\n * `bindEffect(el, name, { trigger })`, `<usa-fx effect trigger>`. Built-ins:\n * every timeline preset (`enter`), `pulse` · `pop` · `jelly` · `wiggle` ·\n * `heartbeat` · `bounce` · `flash` · `tada` · `shake` (attention),\n * `burst` · `confetti` · `ripple` (click). More packs: `motionary/components/effects`.\n */\nimport { defineFx, type UsaFxElement } from './fx-el';\nimport { registerEffects } from './registry';\nimport { BUILTIN_EFFECTS } from './builtins';\n\nexport { defineFx };\nexport { registerEffect, registerEffects, playEffect, bindEffect, getEffect, hasEffect, listEffects, EFFECT_KINDS, EFFECT_TRIGGERS } from './registry';\nexport type { EffectDefinition, EffectContext, EffectKind, EffectTrigger } from './registry';\nexport { BUILTIN_EFFECTS };\nexport type { UsaFxElement };\n\n/** Register the built-in effects (idempotent; `defineFxComponents()` calls it). */\nexport function registerBuiltinEffects(): void {\n registerEffects(BUILTIN_EFFECTS);\n}\n\n/** Register every component of this category under its default tag (+ the built-in effects). */\nexport function defineFxComponents(): void {\n registerBuiltinEffects();\n defineFx();\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'usa-fx': UsaFxElement;\n }\n}\n"],"names":[],"mappings":";;;;;AAAA;;;;;;;AAOG;AAGI,MAAM,YAAY,GAAG,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,QAAQ,EAAE,QAAQ;AAGtI,MAAM,eAAe,GAAG,CAAC,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ;AAiCnF,MAAM,QAAQ,GAAG,IAAI,GAAG,EAA4B;AAEpD;SACgB,cAA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AuB,CAAC,GAAG,KAAK,EAAE,GAAG,SAAS,EAAE,GAAG,KAAK;;AC7FpF;;;;;;;AAOG;AAWH;SACgB,sBAAsB,GAAA;IACpC,eAAe,CAAC,eAAe,CAAC;AAClC;AAEA;SACgB,kBAAkB,GAAA;AAChC,IAAA,sBAAsB,EAAE;AACxB,IAAA,QAAQ,EAAE;AACZ;;;;"}
|
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var base = require('../chunks/base-BaQV-2ha.cjs');
|
|
4
|
+
var spring = require('../chunks/spring-Dgx187Vh.cjs');
|
|
5
|
+
var core = require('../chunks/core-zq17EeCI.cjs');
|
|
6
|
+
|
|
7
|
+
var css = "usa-swipeable{display:block;touch-action:pan-y;user-select:none;-webkit-user-select:none}usa-swipeable[axis=\"y\"]{touch-action:pan-x}usa-swipeable>*{transform:translate3d(var(--usa-swipe,0px),0,0);opacity:calc(1 - var(--usa-swipe-p,0) * 0.5)}usa-swipeable[axis=\"y\"]>*{transform:translate3d(0,var(--usa-swipe,0px),0)}usa-swipeable:focus-visible{outline:2px solid currentColor;outline-offset:2px}usa-pinch-zoom{display:block;overflow:hidden;touch-action:none;position:relative}usa-pinch-zoom>*{transform:translate3d(var(--usa-zoom-x,0px),var(--usa-zoom-y,0px),0) scale(var(--usa-zoom,1));transform-origin:50% 50%}usa-pinch-zoom[data-zoomed]{cursor:grab}usa-pinch-zoom:focus-visible{outline:2px solid currentColor;outline-offset:2px}";
|
|
8
|
+
|
|
9
|
+
function defineSwipeable(tag = 'usa-swipeable') {
|
|
10
|
+
return base.defineElement(tag, (Base) => class UsaSwipeable extends Base {
|
|
11
|
+
constructor() {
|
|
12
|
+
super(...arguments);
|
|
13
|
+
this._off = 0;
|
|
14
|
+
}
|
|
15
|
+
static get observedAttributes() {
|
|
16
|
+
return ['axis', 'disabled'];
|
|
17
|
+
}
|
|
18
|
+
get offset() {
|
|
19
|
+
return this._off;
|
|
20
|
+
}
|
|
21
|
+
put(v) {
|
|
22
|
+
this._off = v;
|
|
23
|
+
this.style.setProperty('--usa-swipe', `${v}px`);
|
|
24
|
+
this.style.setProperty('--usa-swipe-p', String(Math.min(1, Math.abs(v) / this.num('distance', 120))));
|
|
25
|
+
}
|
|
26
|
+
swipe(direction) {
|
|
27
|
+
if (!this.emit('swipe', { direction }))
|
|
28
|
+
return this.reset();
|
|
29
|
+
const sign = direction === 'left' || direction === 'up' ? -1 : 1;
|
|
30
|
+
const far = sign * ((this.str('axis', 'x') === 'y' ? this.offsetHeight : this.offsetWidth) + 80 || 600);
|
|
31
|
+
const done = () => {
|
|
32
|
+
this.emit('dismiss', { direction });
|
|
33
|
+
if (this.flag('dismiss'))
|
|
34
|
+
this.remove();
|
|
35
|
+
};
|
|
36
|
+
if (this.reduced) {
|
|
37
|
+
this.put(0);
|
|
38
|
+
return done();
|
|
39
|
+
}
|
|
40
|
+
this.setAttribute('data-gone', '');
|
|
41
|
+
this._s = spring.createSpring({ spring: 'stiff', value: this._off, onUpdate: (v) => this.put(v), onRest: done });
|
|
42
|
+
this._s.set(far, sign * 1500);
|
|
43
|
+
}
|
|
44
|
+
reset() {
|
|
45
|
+
this.removeAttribute('data-gone');
|
|
46
|
+
if (this.reduced)
|
|
47
|
+
return this.put(0);
|
|
48
|
+
this._s.set(0);
|
|
49
|
+
}
|
|
50
|
+
mount() {
|
|
51
|
+
this._s = spring.createSpring({ spring: this.str('preset', 'default'), onUpdate: (v) => this.put(v) });
|
|
52
|
+
if (!this.hasAttribute('tabindex'))
|
|
53
|
+
this.tabIndex = 0;
|
|
54
|
+
const y = this.str('axis', 'x') === 'y';
|
|
55
|
+
const max = () => this.num('distance', 120);
|
|
56
|
+
this.onCleanup(core.gesture(this, {
|
|
57
|
+
onPan: ({ dx, dy, vx, vy, last }) => {
|
|
58
|
+
if (this.flag('disabled'))
|
|
59
|
+
return;
|
|
60
|
+
const d = y ? dy : dx;
|
|
61
|
+
if (!last) {
|
|
62
|
+
this._s.stop();
|
|
63
|
+
if (!this.reduced)
|
|
64
|
+
this.put(Math.abs(d) > max() ? Math.sign(d) * (max() + (Math.abs(d) - max()) * 0.35) : d);
|
|
65
|
+
return;
|
|
66
|
+
}
|
|
67
|
+
if (Math.abs(d) > max())
|
|
68
|
+
this.swipe(y ? (d > 0 ? 'down' : 'up') : d > 0 ? 'right' : 'left');
|
|
69
|
+
else if (!this.hasAttribute('data-gone')) {
|
|
70
|
+
if (this.reduced)
|
|
71
|
+
this.put(0);
|
|
72
|
+
else
|
|
73
|
+
this._s.set(0, y ? vy : vx);
|
|
74
|
+
}
|
|
75
|
+
},
|
|
76
|
+
onSwipe: ({ direction }) => {
|
|
77
|
+
if (this.flag('disabled') || this.hasAttribute('data-gone'))
|
|
78
|
+
return;
|
|
79
|
+
if (y === (direction === 'up' || direction === 'down'))
|
|
80
|
+
this.swipe(direction);
|
|
81
|
+
},
|
|
82
|
+
}, { axis: y ? 'y' : 'x' }));
|
|
83
|
+
this.listen(this, 'keydown', (e) => {
|
|
84
|
+
if (this.flag('disabled'))
|
|
85
|
+
return;
|
|
86
|
+
const map = y ? { ArrowUp: 'up', ArrowDown: 'down' } : { ArrowLeft: 'left', ArrowRight: 'right' };
|
|
87
|
+
if (e.key === 'Delete' || e.key === 'Backspace')
|
|
88
|
+
this.swipe(y ? 'up' : 'left');
|
|
89
|
+
else if (map[e.key])
|
|
90
|
+
this.swipe(map[e.key]);
|
|
91
|
+
else
|
|
92
|
+
return;
|
|
93
|
+
e.preventDefault();
|
|
94
|
+
});
|
|
95
|
+
}
|
|
96
|
+
unmount() {
|
|
97
|
+
this._s?.stop();
|
|
98
|
+
}
|
|
99
|
+
}, { id: 'gesture', text: css });
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
function definePinchZoom(tag = 'usa-pinch-zoom') {
|
|
103
|
+
return base.defineElement(tag, (Base) => class UsaPinchZoom extends Base {
|
|
104
|
+
constructor() {
|
|
105
|
+
super(...arguments);
|
|
106
|
+
this._v = { k: 1, x: 0, y: 0 };
|
|
107
|
+
}
|
|
108
|
+
get scale() {
|
|
109
|
+
return this._v.k;
|
|
110
|
+
}
|
|
111
|
+
paint() {
|
|
112
|
+
const { k, x, y } = this._v;
|
|
113
|
+
this.style.setProperty('--usa-zoom', String(k));
|
|
114
|
+
this.style.setProperty('--usa-zoom-x', `${x}px`);
|
|
115
|
+
this.style.setProperty('--usa-zoom-y', `${y}px`);
|
|
116
|
+
this.toggleAttribute('data-zoomed', k > 1.01);
|
|
117
|
+
}
|
|
118
|
+
bound(k, x, y) {
|
|
119
|
+
const w = (this.clientWidth * (k - 1)) / 2;
|
|
120
|
+
const h = (this.clientHeight * (k - 1)) / 2;
|
|
121
|
+
return { x: base.clamp(x, -w, w), y: base.clamp(y, -h, h) };
|
|
122
|
+
}
|
|
123
|
+
zoomTo(scale) {
|
|
124
|
+
const k = base.clamp(scale, this.num('min', 1), this.num('max', 4));
|
|
125
|
+
const b = this.bound(k, this._v.x, this._v.y);
|
|
126
|
+
if (this.reduced) {
|
|
127
|
+
this._v = { k, ...b };
|
|
128
|
+
this.paint();
|
|
129
|
+
}
|
|
130
|
+
else {
|
|
131
|
+
this._k.set(k);
|
|
132
|
+
this._x.set(b.x);
|
|
133
|
+
this._y.set(b.y);
|
|
134
|
+
}
|
|
135
|
+
this.emit('zoom', { scale: k });
|
|
136
|
+
}
|
|
137
|
+
mount() {
|
|
138
|
+
const preset = this.str('preset', 'gentle');
|
|
139
|
+
this._k = spring.createSpring({ spring: preset, value: this._v.k, onUpdate: (v) => ((this._v.k = v), this.paint()) });
|
|
140
|
+
this._x = spring.createSpring({ spring: preset, value: this._v.x, onUpdate: (v) => ((this._v.x = v), this.paint()) });
|
|
141
|
+
this._y = spring.createSpring({ spring: preset, value: this._v.y, onUpdate: (v) => ((this._v.y = v), this.paint()) });
|
|
142
|
+
if (!this.hasAttribute('tabindex'))
|
|
143
|
+
this.tabIndex = 0;
|
|
144
|
+
let base$1 = 1;
|
|
145
|
+
let ox = 0;
|
|
146
|
+
let oy = 0;
|
|
147
|
+
this.onCleanup(core.gesture(this, {
|
|
148
|
+
onPinch: ({ scale, first, last }) => {
|
|
149
|
+
if (first)
|
|
150
|
+
base$1 = this._v.k;
|
|
151
|
+
const k = base.clamp(base$1 * scale, this.num('min', 1) * 0.7, this.num('max', 4) * 1.3);
|
|
152
|
+
if (last)
|
|
153
|
+
return this.zoomTo(k);
|
|
154
|
+
this._k.jump(k);
|
|
155
|
+
},
|
|
156
|
+
onPan: ({ dx, dy, vx, vy, first, last }) => {
|
|
157
|
+
if (this._v.k <= 1.01)
|
|
158
|
+
return;
|
|
159
|
+
if (first)
|
|
160
|
+
((ox = this._v.x), (oy = this._v.y));
|
|
161
|
+
if (!last) {
|
|
162
|
+
this._x.jump(ox + dx);
|
|
163
|
+
this._y.jump(oy + dy);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
const b = this.bound(this._v.k, ox + dx + vx * 0.15, oy + dy + vy * 0.15);
|
|
167
|
+
this._x.set(b.x, vx);
|
|
168
|
+
this._y.set(b.y, vy);
|
|
169
|
+
},
|
|
170
|
+
onDoubleTap: () => this.zoomTo(this._v.k > 1.01 ? 1 : this.num('double-tap', 2)),
|
|
171
|
+
}));
|
|
172
|
+
this.listen(this, 'keydown', (e) => {
|
|
173
|
+
if (e.key === '+' || e.key === '=')
|
|
174
|
+
this.zoomTo(this._v.k * 1.25);
|
|
175
|
+
else if (e.key === '-')
|
|
176
|
+
this.zoomTo(this._v.k / 1.25);
|
|
177
|
+
else if (e.key === '0')
|
|
178
|
+
this.zoomTo(1);
|
|
179
|
+
else
|
|
180
|
+
return;
|
|
181
|
+
e.preventDefault();
|
|
182
|
+
});
|
|
183
|
+
this.paint();
|
|
184
|
+
}
|
|
185
|
+
unmount() {
|
|
186
|
+
[this._k, this._x, this._y].forEach((s) => s?.stop());
|
|
187
|
+
}
|
|
188
|
+
}, { id: 'gesture', text: css });
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
/**
|
|
192
|
+
* motionary/components/gesture — unified gestures (v3.2).
|
|
193
|
+
* `gesture()` recognises pan, swipe, pinch, long-press, tap and double-tap
|
|
194
|
+
* with release velocities for springs; `<usa-swipeable>` (swipe-to-dismiss)
|
|
195
|
+
* and `<usa-pinch-zoom>` are built on it.
|
|
196
|
+
*/
|
|
197
|
+
/** Register every component of this category under its default tag. */
|
|
198
|
+
function defineGestureComponents() {
|
|
199
|
+
defineSwipeable();
|
|
200
|
+
definePinchZoom();
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
exports.gesture = core.gesture;
|
|
204
|
+
exports.pinchScale = core.pinchScale;
|
|
205
|
+
exports.swipeDirection = core.swipeDirection;
|
|
206
|
+
exports.defineGestureComponents = defineGestureComponents;
|
|
207
|
+
exports.definePinchZoom = definePinchZoom;
|
|
208
|
+
exports.defineSwipeable = defineSwipeable;
|
|
209
|
+
//# sourceMappingURL=gesture.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gesture.cjs","sources":["../../src/components/gesture/swipeable.ts","../../src/components/gesture/pinch-zoom.ts","../../src/components/gesture/index.ts"],"sourcesContent":["import { defineElement, type UsaElement } from '../base';\nimport { createSpring, type SpringValue } from '../physics/spring';\nimport { gesture, type SwipeDirection } from './core';\nimport css from './gesture.css?raw';\n\n/**\n * `<usa-swipeable>` — swipe-to-dismiss / swipe actions. The content follows\n * the finger (rubber-banded past `distance`), flies out on a swipe or a drag\n * past `distance`, otherwise springs home with the release velocity.\n *\n * Attributes: `axis` (`x` default · `y`), `distance` (px, 120), `preset`\n * (spring), `dismiss` (remove the element after flying out), `disabled`.\n * Keyboard: Delete/Backspace dismisses, ←/→ swipe. Events `usa:swipe`\n * (`{ direction }`, cancelable), `usa:dismiss`. Methods `swipe(dir)`, `reset()`.\n * Reduced motion: no follow / fly-out animation, events still fire.\n */\nexport interface UsaSwipeableElement extends UsaElement {\n swipe(direction: SwipeDirection): void;\n reset(): void;\n readonly offset: number;\n}\n\nexport function defineSwipeable(tag = 'usa-swipeable'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) =>\n class UsaSwipeable extends Base {\n static get observedAttributes(): string[] {\n return ['axis', 'disabled'];\n }\n private _s!: SpringValue;\n private _off = 0;\n\n get offset(): number {\n return this._off;\n }\n\n private put(v: number): void {\n this._off = v;\n this.style.setProperty('--usa-swipe', `${v}px`);\n this.style.setProperty('--usa-swipe-p', String(Math.min(1, Math.abs(v) / this.num('distance', 120))));\n }\n\n swipe(direction: SwipeDirection): void {\n if (!this.emit('swipe', { direction })) return this.reset();\n const sign = direction === 'left' || direction === 'up' ? -1 : 1;\n const far = sign * ((this.str('axis', 'x') === 'y' ? this.offsetHeight : this.offsetWidth) + 80 || 600);\n const done = () => {\n this.emit('dismiss', { direction });\n if (this.flag('dismiss')) this.remove();\n };\n if (this.reduced) {\n this.put(0);\n return done();\n }\n this.setAttribute('data-gone', '');\n this._s = createSpring({ spring: 'stiff', value: this._off, onUpdate: (v) => this.put(v), onRest: done });\n this._s.set(far, sign * 1500);\n }\n\n reset(): void {\n this.removeAttribute('data-gone');\n if (this.reduced) return this.put(0);\n this._s.set(0);\n }\n\n mount(): void {\n this._s = createSpring({ spring: this.str('preset', 'default'), onUpdate: (v) => this.put(v) });\n if (!this.hasAttribute('tabindex')) this.tabIndex = 0;\n const y = this.str('axis', 'x') === 'y';\n const max = () => this.num('distance', 120);\n this.onCleanup(\n gesture(this, {\n onPan: ({ dx, dy, vx, vy, last }) => {\n if (this.flag('disabled')) return;\n const d = y ? dy : dx;\n if (!last) {\n this._s.stop();\n if (!this.reduced) this.put(Math.abs(d) > max() ? Math.sign(d) * (max() + (Math.abs(d) - max()) * 0.35) : d);\n return;\n }\n if (Math.abs(d) > max()) this.swipe(y ? (d > 0 ? 'down' : 'up') : d > 0 ? 'right' : 'left');\n else if (!this.hasAttribute('data-gone')) {\n if (this.reduced) this.put(0);\n else this._s.set(0, y ? vy : vx);\n }\n },\n onSwipe: ({ direction }) => {\n if (this.flag('disabled') || this.hasAttribute('data-gone')) return;\n if (y === (direction === 'up' || direction === 'down')) this.swipe(direction);\n },\n }, { axis: y ? 'y' : 'x' })\n );\n this.listen(this, 'keydown', (e: KeyboardEvent) => {\n if (this.flag('disabled')) return;\n const map: Record<string, SwipeDirection> = y ? { ArrowUp: 'up', ArrowDown: 'down' } : { ArrowLeft: 'left', ArrowRight: 'right' };\n if (e.key === 'Delete' || e.key === 'Backspace') this.swipe(y ? 'up' : 'left');\n else if (map[e.key]) this.swipe(map[e.key]);\n else return;\n e.preventDefault();\n });\n }\n\n unmount(): void {\n this._s?.stop();\n }\n },\n { id: 'gesture', text: css }\n );\n}\n","import { defineElement, clamp, type UsaElement } from '../base';\nimport { createSpring, type SpringValue } from '../physics/spring';\nimport { gesture } from './core';\nimport css from './gesture.css?raw';\n\n/**\n * `<usa-pinch-zoom>` — pinch (two fingers or Ctrl/⌘ + wheel / trackpad\n * pinch) to zoom its content, pan while zoomed, double-tap to toggle zoom;\n * scale and position spring back inside the bounds on release.\n *\n * Attributes: `min` (1), `max` (4), `double-tap` (zoom level, 2), `preset`.\n * Keyboard: `+` / `-` / `0`. Property `scale`, method `zoomTo(scale)`.\n * Event `usa:zoom` (`{ scale }`). Reduced motion: zoom changes instantly.\n */\nexport interface UsaPinchZoomElement extends UsaElement {\n readonly scale: number;\n zoomTo(scale: number): void;\n}\n\nexport function definePinchZoom(tag = 'usa-pinch-zoom'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) =>\n class UsaPinchZoom extends Base {\n private _k!: SpringValue;\n private _x!: SpringValue;\n private _y!: SpringValue;\n private _v = { k: 1, x: 0, y: 0 };\n\n get scale(): number {\n return this._v.k;\n }\n\n private paint(): void {\n const { k, x, y } = this._v;\n this.style.setProperty('--usa-zoom', String(k));\n this.style.setProperty('--usa-zoom-x', `${x}px`);\n this.style.setProperty('--usa-zoom-y', `${y}px`);\n this.toggleAttribute('data-zoomed', k > 1.01);\n }\n\n private bound(k: number, x: number, y: number) {\n const w = (this.clientWidth * (k - 1)) / 2;\n const h = (this.clientHeight * (k - 1)) / 2;\n return { x: clamp(x, -w, w), y: clamp(y, -h, h) };\n }\n\n zoomTo(scale: number): void {\n const k = clamp(scale, this.num('min', 1), this.num('max', 4));\n const b = this.bound(k, this._v.x, this._v.y);\n if (this.reduced) {\n this._v = { k, ...b };\n this.paint();\n } else {\n this._k.set(k);\n this._x.set(b.x);\n this._y.set(b.y);\n }\n this.emit('zoom', { scale: k });\n }\n\n mount(): void {\n const preset = this.str('preset', 'gentle');\n this._k = createSpring({ spring: preset, value: this._v.k, onUpdate: (v) => ((this._v.k = v), this.paint()) });\n this._x = createSpring({ spring: preset, value: this._v.x, onUpdate: (v) => ((this._v.x = v), this.paint()) });\n this._y = createSpring({ spring: preset, value: this._v.y, onUpdate: (v) => ((this._v.y = v), this.paint()) });\n if (!this.hasAttribute('tabindex')) this.tabIndex = 0;\n let base = 1;\n let ox = 0;\n let oy = 0;\n this.onCleanup(\n gesture(this, {\n onPinch: ({ scale, first, last }) => {\n if (first) base = this._v.k;\n const k = clamp(base * scale, this.num('min', 1) * 0.7, this.num('max', 4) * 1.3);\n if (last) return this.zoomTo(k);\n this._k.jump(k);\n },\n onPan: ({ dx, dy, vx, vy, first, last }) => {\n if (this._v.k <= 1.01) return;\n if (first) ((ox = this._v.x), (oy = this._v.y));\n if (!last) {\n this._x.jump(ox + dx);\n this._y.jump(oy + dy);\n return;\n }\n const b = this.bound(this._v.k, ox + dx + vx * 0.15, oy + dy + vy * 0.15);\n this._x.set(b.x, vx);\n this._y.set(b.y, vy);\n },\n onDoubleTap: () => this.zoomTo(this._v.k > 1.01 ? 1 : this.num('double-tap', 2)),\n })\n );\n this.listen(this, 'keydown', (e: KeyboardEvent) => {\n if (e.key === '+' || e.key === '=') this.zoomTo(this._v.k * 1.25);\n else if (e.key === '-') this.zoomTo(this._v.k / 1.25);\n else if (e.key === '0') this.zoomTo(1);\n else return;\n e.preventDefault();\n });\n this.paint();\n }\n\n unmount(): void {\n [this._k, this._x, this._y].forEach((s) => s?.stop());\n }\n },\n { id: 'gesture', text: css }\n );\n}\n","/**\n * motionary/components/gesture — unified gestures (v3.2).\n * `gesture()` recognises pan, swipe, pinch, long-press, tap and double-tap\n * with release velocities for springs; `<usa-swipeable>` (swipe-to-dismiss)\n * and `<usa-pinch-zoom>` are built on it.\n */\nimport { defineSwipeable, type UsaSwipeableElement } from './swipeable';\nimport { definePinchZoom, type UsaPinchZoomElement } from './pinch-zoom';\n\nexport { defineSwipeable, definePinchZoom };\nexport { gesture, swipeDirection, pinchScale } from './core';\nexport type { GestureHandlers, GestureOptions, PanState, SwipeState, SwipeDirection, PinchState, PressState } from './core';\nexport type { UsaSwipeableElement, UsaPinchZoomElement };\n\n/** Register every component of this category under its default tag. */\nexport function defineGestureComponents(): void {\n defineSwipeable();\n definePinchZoom();\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'usa-swipeable': UsaSwipeableElement;\n 'usa-pinch-zoom': UsaPinchZoomElement;\n }\n}\n"],"names":["defineElement","createSpring","gesture","clamp","base"],"mappings":";;;;;;;;AAsBM,SAAU,eAAe,CAAC,GAAG,GAAG,eAAe,EAAA;AACnD,IAAA,OAAOA,kBAAa,CAClB,GAAG,EACH,CAAC,IAAI,KACH,MAAM,YAAa,SAAQ,IAAI,CAAA;AAA/B,QAAA,WAAA,GAAA;;YAKU,IAAA,CAAA,IAAI,GAAG,CAAC;QA2ElB;AA/EE,QAAA,WAAW,kBAAkB,GAAA;AAC3B,YAAA,OAAO,CAAC,MAAM,EAAE,UAAU,CAAC;QAC7B;AAIA,QAAA,IAAI,MAAM,GAAA;YACR,OAAO,IAAI,CAAC,IAAI;QAClB;AAEQ,QAAA,GAAG,CAAC,CAAS,EAAA;AACnB,YAAA,IAAI,CAAC,IAAI,GAAG,CAAC;YACb,IAAI,CAAC,KAAK,CAAC,WAAW,CAAC,aAAa,EAAE,CAAA,EAAG,CAAC,CAAA,EAAA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S,EAAE,IAAI,EAAE,GAAG,EAAE,CAC7B;AACH;;AC7GA;;;;;AAKG;AASH;SACgB,uBAAuB,GAAA;AACrC,IAAA,eAAe,EAAE;AACjB,IAAA,eAAe,EAAE;AACnB;;;;;;;;;"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
/* motionary/components/gesture */
|
|
2
|
+
.usa-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0}
|
|
3
|
+
usa-swipeable{display:block;touch-action:pan-y;user-select:none;-webkit-user-select:none}usa-swipeable[axis="y"]{touch-action:pan-x}usa-swipeable>*{transform:translate3d(var(--usa-swipe,0px),0,0);opacity:calc(1 - var(--usa-swipe-p,0) * 0.5)}usa-swipeable[axis="y"]>*{transform:translate3d(0,var(--usa-swipe,0px),0)}usa-swipeable:focus-visible{outline:2px solid currentColor;outline-offset:2px}usa-pinch-zoom{display:block;overflow:hidden;touch-action:none;position:relative}usa-pinch-zoom>*{transform:translate3d(var(--usa-zoom-x,0px),var(--usa-zoom-y,0px),0) scale(var(--usa-zoom,1));transform-origin:50% 50%}usa-pinch-zoom[data-zoomed]{cursor:grab}usa-pinch-zoom:focus-visible{outline:2px solid currentColor;outline-offset:2px}
|