motionary 10.6.0 → 10.8.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/AGENTS.md +2 -0
- package/CHANGELOG.md +36 -0
- package/README.md +77 -4
- package/bin/motionary-mcp.mjs +160 -11
- package/dist/chunks/{anim-image-DECLkPH4.cjs → anim-image-BzTQa2k3.cjs} +2 -2
- package/dist/chunks/{anim-image-DECLkPH4.cjs.map → anim-image-BzTQa2k3.cjs.map} +1 -1
- package/dist/chunks/{anim-image-DNghy017.js → anim-image-iD646Q7i.js} +2 -2
- package/dist/chunks/{anim-image-DNghy017.js.map → anim-image-iD646Q7i.js.map} +1 -1
- package/dist/chunks/{keyframes-F6vp6tZZ.js → keyframes-B4zefz0k.js} +2 -2
- package/dist/chunks/{keyframes-F6vp6tZZ.js.map → keyframes-B4zefz0k.js.map} +1 -1
- package/dist/chunks/{keyframes-CbUZjD_5.cjs → keyframes-BlOyB1PP.cjs} +2 -2
- package/dist/chunks/{keyframes-CbUZjD_5.cjs.map → keyframes-BlOyB1PP.cjs.map} +1 -1
- package/dist/chunks/{registry-dr1CPTk1.cjs → registry-BZxDVL3h.cjs} +2 -2
- package/dist/chunks/{registry-dr1CPTk1.cjs.map → registry-BZxDVL3h.cjs.map} +1 -1
- package/dist/chunks/{registry-D8LAoXI-.js → registry-Bkt3-3ET.js} +3 -3
- package/dist/chunks/{registry-D8LAoXI-.js.map → registry-Bkt3-3ET.js.map} +1 -1
- package/dist/chunks/runtime-link-CUiZ8lbE.cjs +38 -0
- package/dist/chunks/runtime-link-CUiZ8lbE.cjs.map +1 -0
- package/dist/chunks/runtime-link-c13gskBZ.js +36 -0
- package/dist/chunks/runtime-link-c13gskBZ.js.map +1 -0
- package/dist/chunks/{ticker-DaAlEyOd.cjs → ticker-BfxAECfO.cjs} +2 -2
- package/dist/chunks/{ticker-DaAlEyOd.cjs.map → ticker-BfxAECfO.cjs.map} +1 -1
- package/dist/chunks/{ticker-Do9bGsaV.js → ticker-ZtweD3U4.js} +2 -2
- package/dist/chunks/{ticker-Do9bGsaV.js.map → ticker-ZtweD3U4.js.map} +1 -1
- package/dist/chunks/{tween-CmkdSyaC.cjs → tween--MD-39y0.cjs} +2 -2
- package/dist/chunks/{tween-CmkdSyaC.cjs.map → tween--MD-39y0.cjs.map} +1 -1
- package/dist/chunks/{tween-BzCGq_Ba.js → tween-DACdkLyO.js} +2 -2
- package/dist/chunks/{tween-BzCGq_Ba.js.map → tween-DACdkLyO.js.map} +1 -1
- package/dist/components/ai.cjs +314 -0
- package/dist/components/ai.cjs.map +1 -0
- package/dist/components/ai.d.cts +58 -0
- package/dist/components/ai.d.ts +58 -0
- package/dist/components/ai.js +311 -0
- package/dist/components/ai.js.map +1 -0
- package/dist/components/snap-carousel.cjs +216 -0
- package/dist/components/snap-carousel.cjs.map +1 -0
- package/dist/components/snap-carousel.d.cts +80 -0
- package/dist/components/snap-carousel.d.ts +80 -0
- package/dist/components/snap-carousel.js +214 -0
- package/dist/components/snap-carousel.js.map +1 -0
- package/dist/components/widgets.cjs +626 -268
- package/dist/components/widgets.cjs.map +1 -1
- package/dist/components/widgets.d.cts +515 -39
- package/dist/components/widgets.d.ts +515 -39
- package/dist/components/widgets.js +617 -262
- package/dist/components/widgets.js.map +1 -1
- package/dist/llms-full.txt +191 -6
- package/dist/llms.txt +10 -3
- package/dist/manifest.json +497 -19
- package/dist/runtime/drag-snap.cjs +269 -0
- package/dist/runtime/drag-snap.cjs.map +1 -0
- package/dist/runtime/drag-snap.d.cts +109 -0
- package/dist/runtime/drag-snap.d.ts +109 -0
- package/dist/runtime/drag-snap.iife.js +2 -0
- package/dist/runtime/drag-snap.iife.js.map +1 -0
- package/dist/runtime/drag-snap.js +261 -0
- package/dist/runtime/drag-snap.js.map +1 -0
- package/dist/runtime/format-apng.cjs +4 -4
- package/dist/runtime/format-apng.js +4 -4
- package/dist/runtime/format-css.cjs +4 -4
- package/dist/runtime/format-css.js +4 -4
- package/dist/runtime/format-gif.cjs +4 -4
- package/dist/runtime/format-gif.js +4 -4
- package/dist/runtime/format-gltf.cjs +37 -18
- package/dist/runtime/format-gltf.cjs.map +1 -1
- package/dist/runtime/format-gltf.d.cts +18 -2
- package/dist/runtime/format-gltf.d.ts +18 -2
- package/dist/runtime/format-gltf.iife.js +1 -1
- package/dist/runtime/format-gltf.iife.js.map +1 -1
- package/dist/runtime/format-gltf.js +37 -18
- package/dist/runtime/format-gltf.js.map +1 -1
- package/dist/runtime/format-motion.cjs +4 -4
- package/dist/runtime/format-motion.js +4 -4
- package/dist/runtime/format-obj.cjs +1 -1
- package/dist/runtime/format-obj.d.cts +2 -0
- package/dist/runtime/format-obj.d.ts +2 -0
- package/dist/runtime/format-obj.iife.js.map +1 -1
- package/dist/runtime/format-obj.js +1 -1
- package/dist/runtime/format-scene.cjs +241 -0
- package/dist/runtime/format-scene.cjs.map +1 -0
- package/dist/runtime/format-scene.d.cts +349 -0
- package/dist/runtime/format-scene.d.ts +349 -0
- package/dist/runtime/format-scene.iife.js +2 -0
- package/dist/runtime/format-scene.iife.js.map +1 -0
- package/dist/runtime/format-scene.js +233 -0
- package/dist/runtime/format-scene.js.map +1 -0
- package/dist/runtime/format-sprite.cjs +3 -3
- package/dist/runtime/format-sprite.js +3 -3
- package/dist/runtime/format-svg.cjs +3 -3
- package/dist/runtime/format-svg.js +3 -3
- package/dist/runtime/format-webp.cjs +4 -4
- package/dist/runtime/format-webp.js +4 -4
- package/dist/runtime/gl.cjs +17 -4
- package/dist/runtime/gl.cjs.map +1 -1
- package/dist/runtime/gl.d.cts +2 -0
- package/dist/runtime/gl.d.ts +2 -0
- package/dist/runtime/gl.iife.js +1 -1
- package/dist/runtime/gl.iife.js.map +1 -1
- package/dist/runtime/gl.js +17 -4
- package/dist/runtime/gl.js.map +1 -1
- package/dist/runtime/gltf-anim.cjs +251 -0
- package/dist/runtime/gltf-anim.cjs.map +1 -0
- package/dist/runtime/gltf-anim.d.cts +216 -0
- package/dist/runtime/gltf-anim.d.ts +216 -0
- package/dist/runtime/gltf-anim.iife.js +2 -0
- package/dist/runtime/gltf-anim.iife.js.map +1 -0
- package/dist/runtime/gltf-anim.js +243 -0
- package/dist/runtime/gltf-anim.js.map +1 -0
- package/dist/runtime/physics.cjs +739 -0
- package/dist/runtime/physics.cjs.map +1 -0
- package/dist/runtime/physics.d.cts +250 -0
- package/dist/runtime/physics.d.ts +250 -0
- package/dist/runtime/physics.iife.js +2 -0
- package/dist/runtime/physics.iife.js.map +1 -0
- package/dist/runtime/physics.js +731 -0
- package/dist/runtime/physics.js.map +1 -0
- package/dist/runtime/scroll.cjs +2 -2
- package/dist/runtime/scroll.js +2 -2
- package/dist/runtime/smooth.cjs +1 -1
- package/dist/runtime/smooth.js +1 -1
- package/dist/runtime/text.cjs +1 -1
- package/dist/runtime/text.js +1 -1
- package/dist/runtime/vector.cjs +421 -11
- package/dist/runtime/vector.cjs.map +1 -1
- package/dist/runtime/vector.d.cts +20 -4
- package/dist/runtime/vector.d.ts +20 -4
- package/dist/runtime/vector.iife.js +1 -1
- package/dist/runtime/vector.iife.js.map +1 -1
- package/dist/runtime/vector.js +421 -12
- package/dist/runtime/vector.js.map +1 -1
- package/dist/runtime.cjs +3 -3
- package/dist/runtime.d.cts +1 -1
- package/dist/runtime.d.ts +1 -1
- package/dist/runtime.iife.js +1 -1
- package/dist/runtime.iife.js.map +1 -1
- package/dist/runtime.js +5 -5
- package/dist/widgets.umd.js +1 -1
- package/dist/widgets.umd.js.map +1 -1
- package/docs/ROADMAP.md +2 -2
- package/docs/components/README.md +5 -2
- package/docs/components/usa-gl-scene.md +27 -6
- package/docs/components/usa-lottie-player.md +18 -0
- package/docs/components/usa-motion-prompt.md +32 -0
- package/docs/components/usa-physics-playground.md +63 -0
- package/docs/components/usa-snap-carousel.md +68 -0
- package/docs/components.md +95 -3
- package/docs/runtime/drag-snap.md +60 -0
- package/docs/runtime/format-gltf.md +3 -2
- package/docs/runtime/format-scene.md +59 -0
- package/docs/runtime/gltf-anim.md +62 -0
- package/docs/runtime/physics.md +61 -0
- package/docs/runtime/vector.md +3 -2
- package/package.json +61 -1
|
@@ -0,0 +1,311 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `motionary/components/ai` (10.7, AI-assisted motion) — turns a short
|
|
3
|
+
* natural-language description ("fade the cards up slowly when they scroll
|
|
4
|
+
* into view, one after another") into a motion spec: effect, direction,
|
|
5
|
+
* distance, duration, delay, easing, trigger, repeat, stagger, Web
|
|
6
|
+
* Animations keyframes + options, a CSS rule and the Motionary components
|
|
7
|
+
* that do it. English and Chinese phrases. A small deterministic parser —
|
|
8
|
+
* no model, no network — shared by `<usa-motion-prompt>` and the
|
|
9
|
+
* `suggest_motion` tool of `motionary-mcp` (which runs an evaluation set of
|
|
10
|
+
* prompts against it in CI).
|
|
11
|
+
*
|
|
12
|
+
* Pure: no DOM access — safe in Node, workers and SSR.
|
|
13
|
+
*/
|
|
14
|
+
const R = (re, v) => ({ re, v });
|
|
15
|
+
// effects, most specific first ("slide" before "fade" so "slide and fade in" picks slide as the main motion)
|
|
16
|
+
const EFFECTS = [
|
|
17
|
+
R(/type ?writer|typing|types? (?:out|in)|打字/, 'typewriter'),
|
|
18
|
+
R(/count(?:s|ing)? up|counter|tick(?:s|ing)? up|number(?:s)? (?:roll|count)|数字(?:滚动|增长)|计数/, 'count'),
|
|
19
|
+
R(/confetti|particles?|sparkles?|粒子|彩带|烟花/, 'particles'),
|
|
20
|
+
R(/marquee|ticker tape|scroll(?:s|ing)? (?:sideways|horizontally) (?:forever|endlessly)|跑马灯/, 'marquee'),
|
|
21
|
+
R(/parallax|视差/, 'parallax'),
|
|
22
|
+
R(/magnet(?:ic)?|follows? the (?:cursor|mouse|pointer)|磁吸|跟随(?:鼠标|光标)/, 'magnetic'),
|
|
23
|
+
R(/ripple|涟漪|水波/, 'ripple'),
|
|
24
|
+
R(/tilt|3d hover|倾斜/, 'tilt'),
|
|
25
|
+
R(/shake|wiggle|jiggle|wobble|tremble|抖动|摇晃|晃动/, 'shake'),
|
|
26
|
+
R(/pulse|pulsate|heartbeat|throb|breath(?:e|ing)|脉冲|呼吸|心跳/, 'pulse'),
|
|
27
|
+
R(/bounce|bouncing|bouncy entrance|弹跳|弹起|蹦/, 'bounce'),
|
|
28
|
+
R(/flip|翻转/, 'flip'),
|
|
29
|
+
R(/spin|rotate|rotating|rotation|turn(?:s|ing)? around|旋转|转动/, 'rotate'),
|
|
30
|
+
R(/reveal|wipe|unmask|clip(?:-| )path|揭示|遮罩|擦除/, 'reveal'),
|
|
31
|
+
R(/blur|unblur|focus in|模糊/, 'blur'),
|
|
32
|
+
R(/zoom|scale|grow|shrink|pop(?:s)? (?:in|out|up)|enlarge|缩放|放大|缩小|弹出/, 'zoom'),
|
|
33
|
+
R(/slide|slides|sliding|move(?:s)? in|fly(?:ing)? in|swoop|滑入|滑动|飞入|移入/, 'slide'),
|
|
34
|
+
R(/fade|fades|fading|appear|disappear|dissolve|淡入|淡出|渐显|渐隐|出现/, 'fade'),
|
|
35
|
+
];
|
|
36
|
+
const DIRS = [
|
|
37
|
+
// explicit "from the …" first, so "slide in from the left" is not caught by the bare \bleft\b rule below
|
|
38
|
+
R(/from (?:the )?left|从左/, 'right'),
|
|
39
|
+
R(/from (?:the )?right|从右/, 'left'),
|
|
40
|
+
R(/from (?:the )?(?:top|above)|从上/, 'down'),
|
|
41
|
+
R(/from (?:the )?(?:bottom|below)|\bup\b|upward|rise|rises|从下(?:方|面)?|向上|上浮|升起/, 'up'),
|
|
42
|
+
R(/from (?:the )?(?:top|above)|\bdown\b|downward|drop(?:s)? (?:in|down)|fall(?:s)? in|从上(?:方|面)?|向下|落下/, 'down'),
|
|
43
|
+
R(/from (?:the )?right|\bleft(?:ward)?\b|向左|从右/, 'left'),
|
|
44
|
+
R(/from (?:the )?left|\bright(?:ward)?\b|向右|从左/, 'right'),
|
|
45
|
+
];
|
|
46
|
+
const TRIGGERS = [
|
|
47
|
+
R(/hover|mouse ?over|on mouse|pointer (?:over|enter)|悬停|鼠标(?:移入|悬浮|经过)/, 'hover'),
|
|
48
|
+
R(/click|tap|press|点击|按下|轻触/, 'click'),
|
|
49
|
+
R(/scroll|in(?:to)? view|on screen|viewport|visible|as (?:you|the user) scroll|滚动|进入(?:视口|视野|屏幕)|可见/, 'scroll'),
|
|
50
|
+
R(/forever|infinite(?:ly)?|endless(?:ly)?|loop(?:s|ing)?|continuous(?:ly)?|repeat(?:s|edly|ing)?(?! once)|always|循环|一直|无限|反复/, 'loop'),
|
|
51
|
+
R(/on (?:page )?load|when the page loads|on (?:start|mount)|at start|页面加载|加载时|进入页面/, 'load'),
|
|
52
|
+
];
|
|
53
|
+
const EASINGS = [
|
|
54
|
+
R(/spring(?:y)?|elastic|弹簧|弹性/, ['spring', 'cubic-bezier(0.34, 1.56, 0.64, 1)']),
|
|
55
|
+
R(/bouncy|overshoot|playful|回弹|俏皮/, ['bouncy', 'cubic-bezier(0.68, -0.55, 0.27, 1.55)']),
|
|
56
|
+
R(/linear(?:ly)?|constant speed|steady|匀速|线性/, ['linear', 'linear']),
|
|
57
|
+
R(/snappy|crisp|quick and sharp|干脆|利落/, ['snappy', 'cubic-bezier(0.2, 0.9, 0.1, 1)']),
|
|
58
|
+
R(/ease[- ]?in[- ]?out|smooth(?:ly)?|gentle|gently|soft(?:ly)?|subtle|平滑|柔和|顺滑|轻柔/, ['smooth', 'cubic-bezier(0.65, 0, 0.35, 1)']),
|
|
59
|
+
R(/ease[- ]?in\b|accelerat|speeds? up|加速/, ['ease-in', 'cubic-bezier(0.4, 0, 1, 1)']),
|
|
60
|
+
R(/ease[- ]?out|decelerat|slows? down|减速/, ['ease-out', 'cubic-bezier(0, 0, 0.2, 1)']),
|
|
61
|
+
];
|
|
62
|
+
const num = (s) => parseFloat(s.replace(',', '.'));
|
|
63
|
+
function parseDuration(t, matched) {
|
|
64
|
+
const m = /(\d+(?:[.,]\d+)?)\s*(ms|milliseconds?|毫秒|s\b|secs?|seconds?|秒)/.exec(t);
|
|
65
|
+
if (m) {
|
|
66
|
+
matched.push(m[0]);
|
|
67
|
+
return Math.round(/^(ms|millisecond|毫秒)/.test(m[2]) ? num(m[1]) : num(m[1]) * 1000);
|
|
68
|
+
}
|
|
69
|
+
const w = [
|
|
70
|
+
[/very slow(?:ly)?|really slow|非常慢|很慢/, 1600],
|
|
71
|
+
[/slow(?:ly)?|leisurely|缓慢|慢慢|慢/, 1000],
|
|
72
|
+
[/very fast|really fast|instant(?:ly)?|非常快|很快|瞬间/, 180],
|
|
73
|
+
[/fast|quick(?:ly)?|rapid(?:ly)?|snappy|brisk|快速|快/, 300],
|
|
74
|
+
];
|
|
75
|
+
for (const [re, v] of w) {
|
|
76
|
+
const x = re.exec(t);
|
|
77
|
+
if (x) {
|
|
78
|
+
matched.push(x[0]);
|
|
79
|
+
return v;
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
return null;
|
|
83
|
+
}
|
|
84
|
+
function parseDelay(t, matched) {
|
|
85
|
+
const m = /(?:after|delay(?:ed)?(?: by| of)?|wait(?:s|ing)?|延迟|等待)\s*(\d+(?:[.,]\d+)?)\s*(ms|毫秒|s\b|secs?|seconds?|秒)/.exec(t) ||
|
|
86
|
+
// "after a 300ms delay", "a 1 s delay", "延迟 300 毫秒" handled above; the number-first form here
|
|
87
|
+
/(?:after )?(?:a |an )?(\d+(?:[.,]\d+)?)\s*(ms|毫秒|s\b|secs?|seconds?|秒)\s*(?:-\s*)?(?:delay|pause|wait|后)/.exec(t);
|
|
88
|
+
if (!m)
|
|
89
|
+
return 0;
|
|
90
|
+
matched.push(m[0]);
|
|
91
|
+
return Math.round(/^(ms|毫秒)/.test(m[2]) ? num(m[1]) : num(m[1]) * 1000);
|
|
92
|
+
}
|
|
93
|
+
function parseStagger(t, matched) {
|
|
94
|
+
const m = /(\d+)\s*ms\s*(?:apart|between|stagger)|stagger(?:ed)?(?: by)?\s*(\d+)\s*ms/.exec(t);
|
|
95
|
+
if (m) {
|
|
96
|
+
matched.push(m[0]);
|
|
97
|
+
return +(m[1] || m[2]);
|
|
98
|
+
}
|
|
99
|
+
const w = /one (?:after|by) (?:another|one)|stagger(?:ed)?|in sequence|sequentially|each (?:card|item|word|letter|line) in turn|一个接一个|依次|逐个|交错/.exec(t);
|
|
100
|
+
if (w) {
|
|
101
|
+
matched.push(w[0]);
|
|
102
|
+
return 80;
|
|
103
|
+
}
|
|
104
|
+
return 0;
|
|
105
|
+
}
|
|
106
|
+
function parseIterations(t, trigger, matched) {
|
|
107
|
+
const m = /(\d+|once|twice|three times|一次|两次|三次)\s*(?:times|次)?/.exec(t.replace(/\d+(?:[.,]\d+)?\s*(?:ms|s\b|secs?|seconds?|毫秒|秒|px|%|deg|°)/g, ''));
|
|
108
|
+
if (trigger === 'loop')
|
|
109
|
+
return Infinity;
|
|
110
|
+
if (m && /once|一次/.test(m[1]))
|
|
111
|
+
return 1;
|
|
112
|
+
if (m && /twice|两次/.test(m[1]))
|
|
113
|
+
return (matched.push(m[0]), 2);
|
|
114
|
+
if (m && /three|三次/.test(m[1]))
|
|
115
|
+
return (matched.push(m[0]), 3);
|
|
116
|
+
if (m && /^\d+$/.test(m[1]) && /times|次/.test(m[0]))
|
|
117
|
+
return (matched.push(m[0]), +m[1]);
|
|
118
|
+
return 1;
|
|
119
|
+
}
|
|
120
|
+
function parseAmount(t, effect) {
|
|
121
|
+
const px = /(\d+)\s*(?:px|pixels?|像素)/.exec(t);
|
|
122
|
+
const deg = /(\d+)\s*(?:deg|degrees?|°|度)/.exec(t);
|
|
123
|
+
const pct = /(\d+)\s*%/.exec(t);
|
|
124
|
+
if (effect === 'slide' || effect === 'fade' || effect === 'bounce' || effect === 'shake')
|
|
125
|
+
return px ? +px[1] : effect === 'shake' ? 8 : effect === 'bounce' ? 24 : 32;
|
|
126
|
+
if (effect === 'rotate' || effect === 'flip')
|
|
127
|
+
return deg ? +deg[1] : effect === 'flip' ? 180 : /half/.test(t) ? 180 : 360;
|
|
128
|
+
if (effect === 'zoom') {
|
|
129
|
+
if (pct)
|
|
130
|
+
return +pct[1] / 100;
|
|
131
|
+
return /shrink|out\b|缩小/.test(t) ? 1.2 : 0.8;
|
|
132
|
+
}
|
|
133
|
+
if (effect === 'pulse')
|
|
134
|
+
return pct ? 1 + +pct[1] / 100 : 1.06;
|
|
135
|
+
if (effect === 'blur')
|
|
136
|
+
return px ? +px[1] : 8;
|
|
137
|
+
return 0;
|
|
138
|
+
}
|
|
139
|
+
const DIR_XY = { up: [0, 1], down: [0, -1], left: [1, 0], right: [-1, 0] };
|
|
140
|
+
function keyframesFor(i) {
|
|
141
|
+
const [dx, dy] = DIR_XY[i.direction || 'up'];
|
|
142
|
+
const fade = i.effect === 'fade' || i.also.includes('fade');
|
|
143
|
+
const from = {}, to = {};
|
|
144
|
+
const tf = [], tt = [];
|
|
145
|
+
switch (i.effect) {
|
|
146
|
+
case 'slide':
|
|
147
|
+
case 'fade':
|
|
148
|
+
if (i.effect === 'slide' || i.direction) {
|
|
149
|
+
tf.push(`translate(${dx * i.amount}px, ${dy * i.amount}px)`);
|
|
150
|
+
tt.push('translate(0px, 0px)');
|
|
151
|
+
}
|
|
152
|
+
break;
|
|
153
|
+
case 'zoom':
|
|
154
|
+
tf.push(`scale(${i.amount})`);
|
|
155
|
+
tt.push('scale(1)');
|
|
156
|
+
break;
|
|
157
|
+
case 'rotate':
|
|
158
|
+
tf.push(`rotate(${i.direction === 'left' ? -i.amount : i.amount}deg)`);
|
|
159
|
+
tt.push('rotate(0deg)');
|
|
160
|
+
break;
|
|
161
|
+
case 'flip':
|
|
162
|
+
tf.push(`perspective(600px) rotate${i.direction === 'left' || i.direction === 'right' ? 'Y' : 'X'}(${i.amount}deg)`);
|
|
163
|
+
tt.push(`perspective(600px) rotate${i.direction === 'left' || i.direction === 'right' ? 'Y' : 'X'}(0deg)`);
|
|
164
|
+
break;
|
|
165
|
+
case 'blur':
|
|
166
|
+
from.filter = `blur(${i.amount}px)`;
|
|
167
|
+
to.filter = 'blur(0px)';
|
|
168
|
+
break;
|
|
169
|
+
case 'reveal':
|
|
170
|
+
from.clipPath = i.direction === 'left' ? 'inset(0 0 0 100%)' : i.direction === 'right' ? 'inset(0 100% 0 0)' : i.direction === 'down' ? 'inset(0 0 100% 0)' : 'inset(100% 0 0 0)';
|
|
171
|
+
to.clipPath = 'inset(0 0 0 0)';
|
|
172
|
+
break;
|
|
173
|
+
case 'bounce':
|
|
174
|
+
return [
|
|
175
|
+
{ transform: `translateY(${-i.amount}px)`, opacity: fade ? 0 : 1, offset: 0 },
|
|
176
|
+
{ transform: 'translateY(0px)', opacity: 1, offset: 0.55 },
|
|
177
|
+
{ transform: `translateY(${-i.amount * 0.35}px)`, offset: 0.75 },
|
|
178
|
+
{ transform: 'translateY(0px)', offset: 1 },
|
|
179
|
+
];
|
|
180
|
+
case 'shake':
|
|
181
|
+
return [0, 1, -1, 1, -1, 0].map((k, n, a) => ({ transform: `translateX(${k * i.amount}px)`, offset: n / (a.length - 1) }));
|
|
182
|
+
case 'pulse':
|
|
183
|
+
return [{ transform: 'scale(1)' }, { transform: `scale(${i.amount})` }, { transform: 'scale(1)' }];
|
|
184
|
+
}
|
|
185
|
+
if (i.also.includes('zoom') && i.effect !== 'zoom')
|
|
186
|
+
(tf.push('scale(0.85)'), tt.push('scale(1)'));
|
|
187
|
+
if (i.also.includes('rotate') && i.effect !== 'rotate')
|
|
188
|
+
(tf.push('rotate(-8deg)'), tt.push('rotate(0deg)'));
|
|
189
|
+
if (i.also.includes('blur') && i.effect !== 'blur')
|
|
190
|
+
(from.filter = 'blur(6px)'), (to.filter = 'blur(0px)');
|
|
191
|
+
if (tf.length)
|
|
192
|
+
(from.transform = tf.join(' ')), (to.transform = tt.join(' '));
|
|
193
|
+
if (fade || ['slide', 'zoom', 'blur', 'flip'].includes(i.effect))
|
|
194
|
+
(from.opacity = 0), (to.opacity = 1);
|
|
195
|
+
return [from, to];
|
|
196
|
+
}
|
|
197
|
+
const COMPONENTS = {
|
|
198
|
+
typewriter: [['usa-typewriter', 'types text out character by character', '<usa-typewriter text="Hello, Motionary"></usa-typewriter>']],
|
|
199
|
+
count: [['usa-counter', 'animates a number up when it scrolls into view', '<usa-counter to="1280" duration="1200"></usa-counter>']],
|
|
200
|
+
particles: [['usa-particles', 'particle field (Canvas 2D)', '<usa-particles count="80"></usa-particles>'], ['usa-gpu-particles', 'tens of thousands of GPU particles', '<usa-gpu-particles count="20000" mode="swirl"></usa-gpu-particles>']],
|
|
201
|
+
marquee: [['usa-marquee', 'endless horizontal scroller', '<usa-marquee speed="40"><span>…</span></usa-marquee>']],
|
|
202
|
+
parallax: [['usa-parallax-layers', 'layers move at different speeds while scrolling', '<usa-parallax-layers><img data-depth="0.2" src="…"></usa-parallax-layers>']],
|
|
203
|
+
magnetic: [['usa-magnetic', 'element follows the pointer a little', '<usa-magnetic><button>Hover me</button></usa-magnetic>']],
|
|
204
|
+
ripple: [['usa-ripple', 'material-style click ripple', '<usa-ripple><button>Click</button></usa-ripple>']],
|
|
205
|
+
tilt: [['usa-tilt', '3D tilt towards the pointer', '<usa-tilt><div class="card">…</div></usa-tilt>']],
|
|
206
|
+
reveal: [['usa-mask-reveal', 'clip-path reveal on scroll', '<usa-mask-reveal><img src="…"></usa-mask-reveal>'], ['usa-reveal', 'reveal on scroll', '<usa-reveal><div>…</div></usa-reveal>']],
|
|
207
|
+
scroll: [['usa-reveal', 'plays the entrance when the element scrolls into view', '<usa-reveal><div>…</div></usa-reveal>']],
|
|
208
|
+
};
|
|
209
|
+
/** Parse a natural-language motion description. */
|
|
210
|
+
function describeMotion(input) {
|
|
211
|
+
const text = String(input || '').trim();
|
|
212
|
+
const t = text.toLowerCase();
|
|
213
|
+
const matched = [];
|
|
214
|
+
const hits = EFFECTS.filter((r) => {
|
|
215
|
+
const m = r.re.exec(t);
|
|
216
|
+
if (m)
|
|
217
|
+
matched.push(m[0]);
|
|
218
|
+
return !!m;
|
|
219
|
+
}).map((r) => r.v);
|
|
220
|
+
let effect = hits[0] || 'fade';
|
|
221
|
+
// "fade in and slide up": the slide is the motion, the fade rides along
|
|
222
|
+
if (effect === 'fade' && hits.includes('slide'))
|
|
223
|
+
effect = 'slide';
|
|
224
|
+
const also = hits.filter((h) => h !== effect);
|
|
225
|
+
let direction = null;
|
|
226
|
+
for (const r of DIRS) {
|
|
227
|
+
const m = r.re.exec(t);
|
|
228
|
+
if (m && !/(?:in|out)$/.test(m[0]) && !(effect === 'zoom' && /\bup\b/.test(m[0]) && /pop/.test(t))) {
|
|
229
|
+
direction = r.v;
|
|
230
|
+
matched.push(m[0]);
|
|
231
|
+
break;
|
|
232
|
+
}
|
|
233
|
+
}
|
|
234
|
+
if (!direction && effect === 'slide')
|
|
235
|
+
direction = 'up';
|
|
236
|
+
let trigger = 'load';
|
|
237
|
+
const trig = TRIGGERS.filter((r) => r.re.test(t)).map((r) => r.v);
|
|
238
|
+
if (trig.length)
|
|
239
|
+
trigger = trig.includes('hover') ? 'hover' : trig.includes('click') ? 'click' : trig.includes('scroll') && !(trig.includes('loop') && /forever|infinite|endless|无限|一直/.test(t)) ? 'scroll' : trig[0];
|
|
240
|
+
if (['shake', 'pulse'].includes(effect) && trigger === 'load' && /attention|notify|提醒|注意/.test(t))
|
|
241
|
+
trigger = 'loop';
|
|
242
|
+
if (effect === 'marquee')
|
|
243
|
+
trigger = 'loop';
|
|
244
|
+
const easingHit = EASINGS.find((r) => r.re.test(t));
|
|
245
|
+
const easingName = easingHit ? easingHit.v[0] : effect === 'bounce' ? 'bouncy' : effect === 'shake' || effect === 'pulse' ? 'smooth' : 'ease-out';
|
|
246
|
+
const easing = easingHit ? easingHit.v[1] : easingName === 'bouncy' ? 'cubic-bezier(0.68, -0.55, 0.27, 1.55)' : easingName === 'smooth' ? 'cubic-bezier(0.65, 0, 0.35, 1)' : 'cubic-bezier(0, 0, 0.2, 1)';
|
|
247
|
+
if (easingHit)
|
|
248
|
+
matched.push(easingHit.re.exec(t)[0]);
|
|
249
|
+
const duration = parseDuration(t, matched) ?? (effect === 'shake' ? 500 : effect === 'pulse' ? 1200 : effect === 'typewriter' ? 1800 : effect === 'count' ? 1200 : 600);
|
|
250
|
+
const delay = parseDelay(t, matched);
|
|
251
|
+
const stagger = parseStagger(t, matched);
|
|
252
|
+
const iterations = parseIterations(t, trigger, matched);
|
|
253
|
+
const alternate = /back and forth|alternat|yoyo|ping[- ]?pong|往返|来回/.test(t) || (effect === 'pulse' && trigger === 'loop' && false);
|
|
254
|
+
const amount = parseAmount(t, effect);
|
|
255
|
+
const kf = keyframesFor({ effect, also, direction, amount });
|
|
256
|
+
const options = { duration, delay, easing, fill: 'both', iterations, ...(alternate ? { direction: 'alternate' } : {}) };
|
|
257
|
+
const css = cssFor(kf, options, trigger, stagger);
|
|
258
|
+
const comps = [];
|
|
259
|
+
for (const key of [effect, trigger])
|
|
260
|
+
for (const [tag, why, snippet] of COMPONENTS[key] || [])
|
|
261
|
+
if (!comps.some((c) => c.tag === tag))
|
|
262
|
+
comps.push({ tag, why, snippet });
|
|
263
|
+
if (stagger)
|
|
264
|
+
comps.push({ tag: 'usa-stagger', why: 'staggers its children', snippet: `<usa-stagger delay="${stagger}"><div>…</div><div>…</div></usa-stagger>` });
|
|
265
|
+
const understood = matched.join(' ').length;
|
|
266
|
+
const confidence = Math.max(0.1, Math.min(1, (hits.length ? 0.5 : 0.15) + Math.min(0.5, understood / Math.max(12, t.length))));
|
|
267
|
+
return { text, effect, also, direction, amount, duration, delay, easing, easingName, trigger, iterations, alternate, stagger, reducedMotion: 'respect', keyframes: kf, options, css, components: comps, confidence: Math.round(confidence * 100) / 100, matched };
|
|
268
|
+
}
|
|
269
|
+
const kebab = (k) => k.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase());
|
|
270
|
+
function cssFor(kf, o, trigger, stagger) {
|
|
271
|
+
const name = 'usa-motion';
|
|
272
|
+
const frames = kf.map((f, i) => {
|
|
273
|
+
const pct = f.offset != null ? Math.round(f.offset * 100) : Math.round((i / Math.max(1, kf.length - 1)) * 100);
|
|
274
|
+
const props = Object.entries(f).filter(([k]) => k !== 'offset' && k !== 'easing').map(([k, v]) => `${kebab(k)}: ${v};`).join(' ');
|
|
275
|
+
return ` ${pct}% { ${props} }`;
|
|
276
|
+
});
|
|
277
|
+
const it = o.iterations === Infinity ? 'infinite' : String(o.iterations ?? 1);
|
|
278
|
+
const anim = `${name} ${o.duration}ms ${o.easing} ${o.delay || 0}ms ${it}${o.direction === 'alternate' ? ' alternate' : ''} both`;
|
|
279
|
+
const sel = trigger === 'hover' ? '.target:hover' : trigger === 'click' ? '.target.is-active' : trigger === 'scroll' ? '.target.is-visible' : '.target';
|
|
280
|
+
return [
|
|
281
|
+
`@keyframes ${name} {`,
|
|
282
|
+
...frames,
|
|
283
|
+
'}',
|
|
284
|
+
`${sel} { animation: ${anim}; }`,
|
|
285
|
+
...(stagger ? [`.target:nth-child(n) { animation-delay: calc(var(--i, 0) * ${stagger}ms); }`] : []),
|
|
286
|
+
'@media (prefers-reduced-motion: reduce) { .target { animation: none; } }',
|
|
287
|
+
].join('\n');
|
|
288
|
+
}
|
|
289
|
+
/** Turn an intent into ready code for one element: CSS, WAAPI or a Motionary component. */
|
|
290
|
+
function motionSnippet(i, style = 'waapi') {
|
|
291
|
+
if (style === 'css')
|
|
292
|
+
return i.css;
|
|
293
|
+
if (style === 'component')
|
|
294
|
+
return i.components[0]?.snippet || `<usa-reveal><div class="target">…</div></usa-reveal>`;
|
|
295
|
+
const opts = JSON.stringify({ ...i.options, iterations: i.iterations === Infinity ? 'Infinity' : i.iterations }).replace('"Infinity"', 'Infinity');
|
|
296
|
+
const play = `el.animate(${JSON.stringify(i.keyframes)}, ${opts});`;
|
|
297
|
+
const guard = `if (!matchMedia('(prefers-reduced-motion: reduce)').matches) `;
|
|
298
|
+
switch (i.trigger) {
|
|
299
|
+
case 'hover':
|
|
300
|
+
return `const el = document.querySelector('.target');\nel.addEventListener('pointerenter', () => { ${guard}${play} });`;
|
|
301
|
+
case 'click':
|
|
302
|
+
return `const el = document.querySelector('.target');\nel.addEventListener('click', () => { ${guard}${play} });`;
|
|
303
|
+
case 'scroll':
|
|
304
|
+
return `const io = new IntersectionObserver((entries) => entries.forEach((e, n) => {\n if (!e.isIntersecting) return;\n const el = e.target; io.unobserve(el);\n ${guard}el.animate(${JSON.stringify(i.keyframes)}, { ...${opts}, delay: ${i.delay} + n * ${i.stagger} });\n}), { threshold: 0.2 });\ndocument.querySelectorAll('.target').forEach((el) => io.observe(el));`;
|
|
305
|
+
default:
|
|
306
|
+
return `const el = document.querySelector('.target');\n${guard}${play}`;
|
|
307
|
+
}
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
export { describeMotion, motionSnippet };
|
|
311
|
+
//# sourceMappingURL=ai.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ai.js","sources":["../../src/components/ai/index.ts"],"sourcesContent":["/**\n * `motionary/components/ai` (10.7, AI-assisted motion) — turns a short\n * natural-language description (\"fade the cards up slowly when they scroll\n * into view, one after another\") into a motion spec: effect, direction,\n * distance, duration, delay, easing, trigger, repeat, stagger, Web\n * Animations keyframes + options, a CSS rule and the Motionary components\n * that do it. English and Chinese phrases. A small deterministic parser —\n * no model, no network — shared by `<usa-motion-prompt>` and the\n * `suggest_motion` tool of `motionary-mcp` (which runs an evaluation set of\n * prompts against it in CI).\n *\n * Pure: no DOM access — safe in Node, workers and SSR.\n */\n\nexport type MotionEffect = 'fade' | 'slide' | 'zoom' | 'rotate' | 'flip' | 'bounce' | 'shake' | 'pulse' | 'blur' | 'reveal' | 'typewriter' | 'count' | 'tilt' | 'magnetic' | 'ripple' | 'parallax' | 'marquee' | 'particles';\nexport type MotionTrigger = 'load' | 'scroll' | 'hover' | 'click' | 'loop';\nexport type Direction = 'up' | 'down' | 'left' | 'right' | null;\n\nexport interface MotionIntent {\n /** The input, trimmed. */\n text: string;\n effect: MotionEffect;\n /** Secondary effects mentioned with the main one (\"fade and zoom\"). */\n also: MotionEffect[];\n direction: Direction;\n /** px for slides, scale factor for zooms, degrees for rotations / flips. */\n amount: number;\n duration: number;\n delay: number;\n easing: string;\n /** Named easing the text asked for ('spring', 'bouncy', 'smooth', 'linear', 'snappy', 'ease-out' …). */\n easingName: string;\n trigger: MotionTrigger;\n /** 1 = once, Infinity = forever. */\n iterations: number;\n alternate: boolean;\n /** ms between items for lists / groups (0 = none). */\n stagger: number;\n reducedMotion: 'respect';\n keyframes: Keyframe[];\n options: KeyframeAnimationOptions;\n css: string;\n /** Motionary components that implement it, best first. */\n components: { tag: string; why: string; snippet: string }[];\n /** 0–1: how much of the text was understood. */\n confidence: number;\n /** Words / phrases that drove each decision (for explanations). */\n matched: string[];\n}\n\ninterface Rule<T> { re: RegExp; v: T }\nconst R = <T>(re: RegExp, v: T): Rule<T> => ({ re, v });\n\n// effects, most specific first (\"slide\" before \"fade\" so \"slide and fade in\" picks slide as the main motion)\nconst EFFECTS: Rule<MotionEffect>[] = [\n R(/type ?writer|typing|types? (?:out|in)|打字/, 'typewriter'),\n R(/count(?:s|ing)? up|counter|tick(?:s|ing)? up|number(?:s)? (?:roll|count)|数字(?:滚动|增长)|计数/, 'count'),\n R(/confetti|particles?|sparkles?|粒子|彩带|烟花/, 'particles'),\n R(/marquee|ticker tape|scroll(?:s|ing)? (?:sideways|horizontally) (?:forever|endlessly)|跑马灯/, 'marquee'),\n R(/parallax|视差/, 'parallax'),\n R(/magnet(?:ic)?|follows? the (?:cursor|mouse|pointer)|磁吸|跟随(?:鼠标|光标)/, 'magnetic'),\n R(/ripple|涟漪|水波/, 'ripple'),\n R(/tilt|3d hover|倾斜/, 'tilt'),\n R(/shake|wiggle|jiggle|wobble|tremble|抖动|摇晃|晃动/, 'shake'),\n R(/pulse|pulsate|heartbeat|throb|breath(?:e|ing)|脉冲|呼吸|心跳/, 'pulse'),\n R(/bounce|bouncing|bouncy entrance|弹跳|弹起|蹦/, 'bounce'),\n R(/flip|翻转/, 'flip'),\n R(/spin|rotate|rotating|rotation|turn(?:s|ing)? around|旋转|转动/, 'rotate'),\n R(/reveal|wipe|unmask|clip(?:-| )path|揭示|遮罩|擦除/, 'reveal'),\n R(/blur|unblur|focus in|模糊/, 'blur'),\n R(/zoom|scale|grow|shrink|pop(?:s)? (?:in|out|up)|enlarge|缩放|放大|缩小|弹出/, 'zoom'),\n R(/slide|slides|sliding|move(?:s)? in|fly(?:ing)? in|swoop|滑入|滑动|飞入|移入/, 'slide'),\n R(/fade|fades|fading|appear|disappear|dissolve|淡入|淡出|渐显|渐隐|出现/, 'fade'),\n];\nconst DIRS: Rule<Direction>[] = [\n // explicit \"from the …\" first, so \"slide in from the left\" is not caught by the bare \\bleft\\b rule below\n R(/from (?:the )?left|从左/, 'right'),\n R(/from (?:the )?right|从右/, 'left'),\n R(/from (?:the )?(?:top|above)|从上/, 'down'),\n R(/from (?:the )?(?:bottom|below)|\\bup\\b|upward|rise|rises|从下(?:方|面)?|向上|上浮|升起/, 'up'),\n R(/from (?:the )?(?:top|above)|\\bdown\\b|downward|drop(?:s)? (?:in|down)|fall(?:s)? in|从上(?:方|面)?|向下|落下/, 'down'),\n R(/from (?:the )?right|\\bleft(?:ward)?\\b|向左|从右/, 'left'),\n R(/from (?:the )?left|\\bright(?:ward)?\\b|向右|从左/, 'right'),\n];\nconst TRIGGERS: Rule<MotionTrigger>[] = [\n R(/hover|mouse ?over|on mouse|pointer (?:over|enter)|悬停|鼠标(?:移入|悬浮|经过)/, 'hover'),\n R(/click|tap|press|点击|按下|轻触/, 'click'),\n R(/scroll|in(?:to)? view|on screen|viewport|visible|as (?:you|the user) scroll|滚动|进入(?:视口|视野|屏幕)|可见/, 'scroll'),\n R(/forever|infinite(?:ly)?|endless(?:ly)?|loop(?:s|ing)?|continuous(?:ly)?|repeat(?:s|edly|ing)?(?! once)|always|循环|一直|无限|反复/, 'loop'),\n R(/on (?:page )?load|when the page loads|on (?:start|mount)|at start|页面加载|加载时|进入页面/, 'load'),\n];\nconst EASINGS: Rule<[string, string]>[] = [\n R(/spring(?:y)?|elastic|弹簧|弹性/, ['spring', 'cubic-bezier(0.34, 1.56, 0.64, 1)']),\n R(/bouncy|overshoot|playful|回弹|俏皮/, ['bouncy', 'cubic-bezier(0.68, -0.55, 0.27, 1.55)']),\n R(/linear(?:ly)?|constant speed|steady|匀速|线性/, ['linear', 'linear']),\n R(/snappy|crisp|quick and sharp|干脆|利落/, ['snappy', 'cubic-bezier(0.2, 0.9, 0.1, 1)']),\n R(/ease[- ]?in[- ]?out|smooth(?:ly)?|gentle|gently|soft(?:ly)?|subtle|平滑|柔和|顺滑|轻柔/, ['smooth', 'cubic-bezier(0.65, 0, 0.35, 1)']),\n R(/ease[- ]?in\\b|accelerat|speeds? up|加速/, ['ease-in', 'cubic-bezier(0.4, 0, 1, 1)']),\n R(/ease[- ]?out|decelerat|slows? down|减速/, ['ease-out', 'cubic-bezier(0, 0, 0.2, 1)']),\n];\n\nconst num = (s: string) => parseFloat(s.replace(',', '.'));\nfunction parseDuration(t: string, matched: string[]): number | null {\n const m = /(\\d+(?:[.,]\\d+)?)\\s*(ms|milliseconds?|毫秒|s\\b|secs?|seconds?|秒)/.exec(t);\n if (m) {\n matched.push(m[0]);\n return Math.round(/^(ms|millisecond|毫秒)/.test(m[2]) ? num(m[1]) : num(m[1]) * 1000);\n }\n const w: [RegExp, number][] = [\n [/very slow(?:ly)?|really slow|非常慢|很慢/, 1600],\n [/slow(?:ly)?|leisurely|缓慢|慢慢|慢/, 1000],\n [/very fast|really fast|instant(?:ly)?|非常快|很快|瞬间/, 180],\n [/fast|quick(?:ly)?|rapid(?:ly)?|snappy|brisk|快速|快/, 300],\n ];\n for (const [re, v] of w) {\n const x = re.exec(t);\n if (x) {\n matched.push(x[0]);\n return v;\n }\n }\n return null;\n}\nfunction parseDelay(t: string, matched: string[]): number {\n const m =\n /(?:after|delay(?:ed)?(?: by| of)?|wait(?:s|ing)?|延迟|等待)\\s*(\\d+(?:[.,]\\d+)?)\\s*(ms|毫秒|s\\b|secs?|seconds?|秒)/.exec(t) ||\n // \"after a 300ms delay\", \"a 1 s delay\", \"延迟 300 毫秒\" handled above; the number-first form here\n /(?:after )?(?:a |an )?(\\d+(?:[.,]\\d+)?)\\s*(ms|毫秒|s\\b|secs?|seconds?|秒)\\s*(?:-\\s*)?(?:delay|pause|wait|后)/.exec(t);\n if (!m) return 0;\n matched.push(m[0]);\n return Math.round(/^(ms|毫秒)/.test(m[2]) ? num(m[1]) : num(m[1]) * 1000);\n}\nfunction parseStagger(t: string, matched: string[]): number {\n const m = /(\\d+)\\s*ms\\s*(?:apart|between|stagger)|stagger(?:ed)?(?: by)?\\s*(\\d+)\\s*ms/.exec(t);\n if (m) {\n matched.push(m[0]);\n return +(m[1] || m[2]);\n }\n const w = /one (?:after|by) (?:another|one)|stagger(?:ed)?|in sequence|sequentially|each (?:card|item|word|letter|line) in turn|一个接一个|依次|逐个|交错/.exec(t);\n if (w) {\n matched.push(w[0]);\n return 80;\n }\n return 0;\n}\nfunction parseIterations(t: string, trigger: MotionTrigger, matched: string[]): number {\n const m = /(\\d+|once|twice|three times|一次|两次|三次)\\s*(?:times|次)?/.exec(t.replace(/\\d+(?:[.,]\\d+)?\\s*(?:ms|s\\b|secs?|seconds?|毫秒|秒|px|%|deg|°)/g, ''));\n if (trigger === 'loop') return Infinity;\n if (m && /once|一次/.test(m[1])) return 1;\n if (m && /twice|两次/.test(m[1])) return (matched.push(m[0]), 2);\n if (m && /three|三次/.test(m[1])) return (matched.push(m[0]), 3);\n if (m && /^\\d+$/.test(m[1]) && /times|次/.test(m[0])) return (matched.push(m[0]), +m[1]);\n return 1;\n}\nfunction parseAmount(t: string, effect: MotionEffect): number {\n const px = /(\\d+)\\s*(?:px|pixels?|像素)/.exec(t);\n const deg = /(\\d+)\\s*(?:deg|degrees?|°|度)/.exec(t);\n const pct = /(\\d+)\\s*%/.exec(t);\n if (effect === 'slide' || effect === 'fade' || effect === 'bounce' || effect === 'shake') return px ? +px[1] : effect === 'shake' ? 8 : effect === 'bounce' ? 24 : 32;\n if (effect === 'rotate' || effect === 'flip') return deg ? +deg[1] : effect === 'flip' ? 180 : /half/.test(t) ? 180 : 360;\n if (effect === 'zoom') {\n if (pct) return +pct[1] / 100;\n return /shrink|out\\b|缩小/.test(t) ? 1.2 : 0.8;\n }\n if (effect === 'pulse') return pct ? 1 + +pct[1] / 100 : 1.06;\n if (effect === 'blur') return px ? +px[1] : 8;\n return 0;\n}\n\nconst DIR_XY: Record<string, [number, number]> = { up: [0, 1], down: [0, -1], left: [1, 0], right: [-1, 0] };\n\nfunction keyframesFor(i: Pick<MotionIntent, 'effect' | 'also' | 'direction' | 'amount'>): Keyframe[] {\n const out = /out\\b|disappear|exit|淡出|消失/;\n void out;\n const [dx, dy] = DIR_XY[i.direction || 'up'];\n const fade = i.effect === 'fade' || i.also.includes('fade');\n const from: Keyframe = {}, to: Keyframe = {};\n const tf: string[] = [], tt: string[] = [];\n switch (i.effect) {\n case 'slide':\n case 'fade':\n if (i.effect === 'slide' || i.direction) {\n tf.push(`translate(${dx * i.amount}px, ${dy * i.amount}px)`);\n tt.push('translate(0px, 0px)');\n }\n break;\n case 'zoom':\n tf.push(`scale(${i.amount})`);\n tt.push('scale(1)');\n break;\n case 'rotate':\n tf.push(`rotate(${i.direction === 'left' ? -i.amount : i.amount}deg)`);\n tt.push('rotate(0deg)');\n break;\n case 'flip':\n tf.push(`perspective(600px) rotate${i.direction === 'left' || i.direction === 'right' ? 'Y' : 'X'}(${i.amount}deg)`);\n tt.push(`perspective(600px) rotate${i.direction === 'left' || i.direction === 'right' ? 'Y' : 'X'}(0deg)`);\n break;\n case 'blur':\n from.filter = `blur(${i.amount}px)`;\n to.filter = 'blur(0px)';\n break;\n case 'reveal':\n from.clipPath = i.direction === 'left' ? 'inset(0 0 0 100%)' : i.direction === 'right' ? 'inset(0 100% 0 0)' : i.direction === 'down' ? 'inset(0 0 100% 0)' : 'inset(100% 0 0 0)';\n to.clipPath = 'inset(0 0 0 0)';\n break;\n case 'bounce':\n return [\n { transform: `translateY(${-i.amount}px)`, opacity: fade ? 0 : 1, offset: 0 },\n { transform: 'translateY(0px)', opacity: 1, offset: 0.55 },\n { transform: `translateY(${-i.amount * 0.35}px)`, offset: 0.75 },\n { transform: 'translateY(0px)', offset: 1 },\n ];\n case 'shake':\n return [0, 1, -1, 1, -1, 0].map((k, n, a) => ({ transform: `translateX(${k * i.amount}px)`, offset: n / (a.length - 1) }));\n case 'pulse':\n return [{ transform: 'scale(1)' }, { transform: `scale(${i.amount})` }, { transform: 'scale(1)' }];\n default:\n break;\n }\n if (i.also.includes('zoom') && i.effect !== 'zoom') (tf.push('scale(0.85)'), tt.push('scale(1)'));\n if (i.also.includes('rotate') && i.effect !== 'rotate') (tf.push('rotate(-8deg)'), tt.push('rotate(0deg)'));\n if (i.also.includes('blur') && i.effect !== 'blur') (from.filter = 'blur(6px)'), (to.filter = 'blur(0px)');\n if (tf.length) (from.transform = tf.join(' ')), (to.transform = tt.join(' '));\n if (fade || ['slide', 'zoom', 'blur', 'flip'].includes(i.effect)) (from.opacity = 0), (to.opacity = 1);\n return [from, to];\n}\n\nconst COMPONENTS: Partial<Record<MotionEffect | MotionTrigger, [string, string, string][]>> = {\n typewriter: [['usa-typewriter', 'types text out character by character', '<usa-typewriter text=\"Hello, Motionary\"></usa-typewriter>']],\n count: [['usa-counter', 'animates a number up when it scrolls into view', '<usa-counter to=\"1280\" duration=\"1200\"></usa-counter>']],\n particles: [['usa-particles', 'particle field (Canvas 2D)', '<usa-particles count=\"80\"></usa-particles>'], ['usa-gpu-particles', 'tens of thousands of GPU particles', '<usa-gpu-particles count=\"20000\" mode=\"swirl\"></usa-gpu-particles>']],\n marquee: [['usa-marquee', 'endless horizontal scroller', '<usa-marquee speed=\"40\"><span>…</span></usa-marquee>']],\n parallax: [['usa-parallax-layers', 'layers move at different speeds while scrolling', '<usa-parallax-layers><img data-depth=\"0.2\" src=\"…\"></usa-parallax-layers>']],\n magnetic: [['usa-magnetic', 'element follows the pointer a little', '<usa-magnetic><button>Hover me</button></usa-magnetic>']],\n ripple: [['usa-ripple', 'material-style click ripple', '<usa-ripple><button>Click</button></usa-ripple>']],\n tilt: [['usa-tilt', '3D tilt towards the pointer', '<usa-tilt><div class=\"card\">…</div></usa-tilt>']],\n reveal: [['usa-mask-reveal', 'clip-path reveal on scroll', '<usa-mask-reveal><img src=\"…\"></usa-mask-reveal>'], ['usa-reveal', 'reveal on scroll', '<usa-reveal><div>…</div></usa-reveal>']],\n scroll: [['usa-reveal', 'plays the entrance when the element scrolls into view', '<usa-reveal><div>…</div></usa-reveal>']],\n};\n\n/** Parse a natural-language motion description. */\nexport function describeMotion(input: string): MotionIntent {\n const text = String(input || '').trim();\n const t = text.toLowerCase();\n const matched: string[] = [];\n const hits = EFFECTS.filter((r) => {\n const m = r.re.exec(t);\n if (m) matched.push(m[0]);\n return !!m;\n }).map((r) => r.v);\n let effect: MotionEffect = hits[0] || 'fade';\n // \"fade in and slide up\": the slide is the motion, the fade rides along\n if (effect === 'fade' && hits.includes('slide')) effect = 'slide';\n const also = hits.filter((h) => h !== effect);\n let direction: Direction = null;\n for (const r of DIRS) {\n const m = r.re.exec(t);\n if (m && !/(?:in|out)$/.test(m[0]) && !(effect === 'zoom' && /\\bup\\b/.test(m[0]) && /pop/.test(t))) {\n direction = r.v;\n matched.push(m[0]);\n break;\n }\n }\n if (!direction && effect === 'slide') direction = 'up';\n let trigger: MotionTrigger = 'load';\n const trig = TRIGGERS.filter((r) => r.re.test(t)).map((r) => r.v);\n if (trig.length) trigger = trig.includes('hover') ? 'hover' : trig.includes('click') ? 'click' : trig.includes('scroll') && !(trig.includes('loop') && /forever|infinite|endless|无限|一直/.test(t)) ? 'scroll' : trig[0];\n if (['shake', 'pulse'].includes(effect) && trigger === 'load' && /attention|notify|提醒|注意/.test(t)) trigger = 'loop';\n if (effect === 'marquee') trigger = 'loop';\n const easingHit = EASINGS.find((r) => r.re.test(t));\n const easingName = easingHit ? easingHit.v[0] : effect === 'bounce' ? 'bouncy' : effect === 'shake' || effect === 'pulse' ? 'smooth' : 'ease-out';\n const easing = easingHit ? easingHit.v[1] : easingName === 'bouncy' ? 'cubic-bezier(0.68, -0.55, 0.27, 1.55)' : easingName === 'smooth' ? 'cubic-bezier(0.65, 0, 0.35, 1)' : 'cubic-bezier(0, 0, 0.2, 1)';\n if (easingHit) matched.push(easingHit.re.exec(t)![0]);\n const duration = parseDuration(t, matched) ?? (effect === 'shake' ? 500 : effect === 'pulse' ? 1200 : effect === 'typewriter' ? 1800 : effect === 'count' ? 1200 : 600);\n const delay = parseDelay(t, matched);\n const stagger = parseStagger(t, matched);\n const iterations = parseIterations(t, trigger, matched);\n const alternate = /back and forth|alternat|yoyo|ping[- ]?pong|往返|来回/.test(t) || (effect === 'pulse' && trigger === 'loop' && false);\n const amount = parseAmount(t, effect);\n const kf = keyframesFor({ effect, also, direction, amount });\n const options: KeyframeAnimationOptions = { duration, delay, easing, fill: 'both', iterations, ...(alternate ? { direction: 'alternate' } : {}) };\n const css = cssFor(kf, options, trigger, stagger);\n const comps: MotionIntent['components'] = [];\n for (const key of [effect, trigger] as (MotionEffect | MotionTrigger)[]) for (const [tag, why, snippet] of COMPONENTS[key] || []) if (!comps.some((c) => c.tag === tag)) comps.push({ tag, why, snippet });\n if (stagger) comps.push({ tag: 'usa-stagger', why: 'staggers its children', snippet: `<usa-stagger delay=\"${stagger}\"><div>…</div><div>…</div></usa-stagger>` });\n const understood = matched.join(' ').length;\n const confidence = Math.max(0.1, Math.min(1, (hits.length ? 0.5 : 0.15) + Math.min(0.5, understood / Math.max(12, t.length))));\n return { text, effect, also, direction, amount, duration, delay, easing, easingName, trigger, iterations, alternate, stagger, reducedMotion: 'respect', keyframes: kf, options, css, components: comps, confidence: Math.round(confidence * 100) / 100, matched };\n}\n\nconst kebab = (k: string) => k.replace(/[A-Z]/g, (c) => '-' + c.toLowerCase());\nfunction cssFor(kf: Keyframe[], o: KeyframeAnimationOptions, trigger: MotionTrigger, stagger: number): string {\n const name = 'usa-motion';\n const frames = kf.map((f, i) => {\n const pct = f.offset != null ? Math.round((f.offset as number) * 100) : Math.round((i / Math.max(1, kf.length - 1)) * 100);\n const props = Object.entries(f).filter(([k]) => k !== 'offset' && k !== 'easing').map(([k, v]) => `${kebab(k)}: ${v};`).join(' ');\n return ` ${pct}% { ${props} }`;\n });\n const it = o.iterations === Infinity ? 'infinite' : String(o.iterations ?? 1);\n const anim = `${name} ${o.duration}ms ${o.easing} ${o.delay || 0}ms ${it}${o.direction === 'alternate' ? ' alternate' : ''} both`;\n const sel = trigger === 'hover' ? '.target:hover' : trigger === 'click' ? '.target.is-active' : trigger === 'scroll' ? '.target.is-visible' : '.target';\n return [\n `@keyframes ${name} {`,\n ...frames,\n '}',\n `${sel} { animation: ${anim}; }`,\n ...(stagger ? [`.target:nth-child(n) { animation-delay: calc(var(--i, 0) * ${stagger}ms); }`] : []),\n '@media (prefers-reduced-motion: reduce) { .target { animation: none; } }',\n ].join('\\n');\n}\n\n/** Turn an intent into ready code for one element: CSS, WAAPI or a Motionary component. */\nexport function motionSnippet(i: MotionIntent, style: 'waapi' | 'css' | 'component' = 'waapi'): string {\n if (style === 'css') return i.css;\n if (style === 'component') return i.components[0]?.snippet || `<usa-reveal><div class=\"target\">…</div></usa-reveal>`;\n const opts = JSON.stringify({ ...i.options, iterations: i.iterations === Infinity ? 'Infinity' : i.iterations }).replace('\"Infinity\"', 'Infinity');\n const play = `el.animate(${JSON.stringify(i.keyframes)}, ${opts});`;\n const guard = `if (!matchMedia('(prefers-reduced-motion: reduce)').matches) `;\n switch (i.trigger) {\n case 'hover':\n return `const el = document.querySelector('.target');\\nel.addEventListener('pointerenter', () => { ${guard}${play} });`;\n case 'click':\n return `const el = document.querySelector('.target');\\nel.addEventListener('click', () => { ${guard}${play} });`;\n case 'scroll':\n return `const io = new IntersectionObserver((entries) => entries.forEach((e, n) => {\\n if (!e.isIntersecting) return;\\n const el = e.target; io.unobserve(el);\\n ${guard}el.animate(${JSON.stringify(i.keyframes)}, { ...${opts}, delay: ${i.delay} + n * ${i.stagger} });\\n}), { threshold: 0.2 });\\ndocument.querySelectorAll('.target').forEach((el) => io.observe(el));`;\n default:\n return `const el = document.querySelector('.target');\\n${guard}${play}`;\n }\n}\n"],"names":[],"mappings":"AAAA;;;;;;;;;;;;AAYG;AAuCH,MAAM,CAAC,GAAG,CAAI,EAAU,EAAE,CAAI,MAAe,EAAE,EAAE,EAAE,CAAC,EAAE,CAAC;AAEvD;AACA,MAAM,OAAO,GAAyB;AACpC,IAAA,CAAC,CAAC,0CAA0C,EAAE,YAAY,CAAC;AAC3D,IAAA,CAAC,CAAC,yFAAyF,EAAE,OAAO,CAAC;AACrG,IAAA,CAAC,CAAC,wCAAwC,EAAE,WAAW,CAAC;AACxD,IAAA,CAAC,CAAC,0FAA0F,EAAE,SAAS,CAAC;AACxG,IAAA,CAAC,CAAC,aAAa,EAAE,UAAU,CAAC;AAC5B,IAAA,CAAC,CAAC,oEAAoE,EAAE,UAAU,CAAC;AACnF,IAAA,CAAC,CAAC,cAAc,EAAE,QAAQ,CAAC;AAC3B,IAAA,CAAC,CAAC,kBAAkB,EAAE,MAAM,CAAC;AAC7B,IAAA,CAAC,CAAC,6CAA6C,EAAE,OAAO,CAAC;AACzD,IAAA,CAAC,CAAC,wDAAwD,EAAE,OAAO,CAAC;AACpE,IAAA,CAAC,CAAC,yCAAyC,EAAE,QAAQ,CAAC;AACtD,IAAA,CAAC,CAAC,SAAS,EAAE,MAAM,CAAC;AACpB,IAAA,CAAC,CAAC,2DAA2D,EAAE,QAAQ,CAAC;AACxE,IAAA,CAAC,CAAC,6CAA6C,EAAE,QAAQ,CAAC;AAC1D,IAAA,CAAC,CAAC,yBAAyB,EAAE,MAAM,CAAC;AACpC,IAAA,CAAC,CAAC,oEAAoE,EAAE,MAAM,CAAC;AAC/E,IAAA,CAAC,CAAC,qEAAqE,EAAE,OAAO,CAAC;AACjF,IAAA,CAAC,CAAC,4DAA4D,EAAE,MAAM,CAAC;CACxE;AAC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AAY,CAAC,CAAC,KAAK,UAAU,CAAC,CAAC,OAAO,CAAA,qGAAA,CAAuG;AACjX,QAAA;AACE,YAAA,OAAO,CAAA,+CAAA,EAAkD,KAAK,CAAA,EAAG,IAAI,EAAE;;AAE7E;;"}
|
|
@@ -0,0 +1,216 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var base = require('../chunks/base-DBheNxJu.cjs');
|
|
4
|
+
var runtimeLink = require('../chunks/runtime-link-CUiZ8lbE.cjs');
|
|
5
|
+
require('../chunks/registry-BZxDVL3h.cjs');
|
|
6
|
+
|
|
7
|
+
var css = "usa-snap-carousel{display:block;position:relative;--usa-sc-size:80%;--usa-sc-gap:16px;--usa-sc-accent:#7c5cff}.usa-sc-viewport{overflow:hidden;border-radius:var(--usa-radius,14px);outline:none;cursor:grab}.usa-sc-viewport:focus-visible{box-shadow:0 0 0 2px var(--usa-sc-accent)}usa-snap-carousel[data-dragging] .usa-sc-viewport{cursor:grabbing}.usa-sc-track{display:flex;gap:var(--usa-sc-gap);will-change:transform;user-select:none;-webkit-user-select:none}.usa-sc-track>*{flex:0 0 var(--usa-sc-size);min-width:0;box-sizing:border-box;transition:opacity .3s,transform .3s}.usa-sc-track img{pointer-events:none;-webkit-user-drag:none}usa-snap-carousel:not([data-ready]) .usa-sc-viewport{overflow-x:auto;scroll-snap-type:x mandatory;scrollbar-width:thin}usa-snap-carousel:not([data-ready]) .usa-sc-track>*{scroll-snap-align:center}usa-snap-carousel[data-ready] .usa-sc-track>:not([data-active]){opacity:.55;transform:scale(.94)}.usa-sc-nav{position:absolute;top:calc(50% - 18px);z-index:2;width:36px;height:36px;border-radius:50%;border:0;background:rgba(255,255,255,.9);color:#111;font:600 20px/1 system-ui;cursor:pointer;display:grid;place-items:center;box-shadow:0 4px 14px rgba(0,0,0,.18)}.usa-sc-nav:disabled{opacity:.35;cursor:default}.usa-sc-nav:focus-visible,.usa-sc-dot:focus-visible{outline:2px solid var(--usa-sc-accent);outline-offset:2px}.usa-sc-prev{left:8px}.usa-sc-next{right:8px}.usa-sc-dots{display:flex;justify-content:center;gap:6px;padding-top:10px}.usa-sc-dot{width:8px;height:8px;padding:0;border:0;border-radius:99px;background:color-mix(in srgb,currentColor 30%,transparent);cursor:pointer;transition:width .3s,background .3s}.usa-sc-dot[aria-current=\"true\"]{width:22px;background:var(--usa-sc-accent)}.usa-sc-live{position:absolute;width:1px;height:1px;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;margin:0}@media (prefers-reduced-motion:reduce){.usa-sc-track>*,.usa-sc-dot{transition:none}}";
|
|
8
|
+
|
|
9
|
+
function defineSnapCarousel(tag = 'usa-snap-carousel') {
|
|
10
|
+
return base.defineElement(tag, (Base) => {
|
|
11
|
+
class UsaSnapCarousel extends Base {
|
|
12
|
+
constructor() {
|
|
13
|
+
super(...arguments);
|
|
14
|
+
this.slides = [];
|
|
15
|
+
this.ds = null;
|
|
16
|
+
this.cur = 0;
|
|
17
|
+
this.sync = null;
|
|
18
|
+
}
|
|
19
|
+
static get observedAttributes() {
|
|
20
|
+
return ['align', 'gap', 'autoplay', 'no-controls', 'no-dots', 'label'];
|
|
21
|
+
}
|
|
22
|
+
get length() {
|
|
23
|
+
return this.slides.length;
|
|
24
|
+
}
|
|
25
|
+
get index() {
|
|
26
|
+
return this.cur;
|
|
27
|
+
}
|
|
28
|
+
set index(v) {
|
|
29
|
+
this.goTo(v);
|
|
30
|
+
}
|
|
31
|
+
get controller() {
|
|
32
|
+
return this.ds;
|
|
33
|
+
}
|
|
34
|
+
next() {
|
|
35
|
+
this.goTo(this.cur + 1 >= this.length ? 0 : this.cur + 1);
|
|
36
|
+
}
|
|
37
|
+
prev() {
|
|
38
|
+
this.goTo(this.cur - 1 < 0 ? this.length - 1 : this.cur - 1);
|
|
39
|
+
}
|
|
40
|
+
goTo(i, animate = true) {
|
|
41
|
+
const n = Math.max(0, Math.min(this.length - 1, Math.round(i)));
|
|
42
|
+
if (this.ds)
|
|
43
|
+
this.ds.snapTo(n, animate && !this.reduced);
|
|
44
|
+
else {
|
|
45
|
+
this.slides[n]?.scrollIntoView?.({ block: 'nearest', inline: 'center' });
|
|
46
|
+
this.set(n);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
set(n) {
|
|
50
|
+
if (n === this.cur && this.dataset.ready !== undefined)
|
|
51
|
+
return this.sync?.();
|
|
52
|
+
const from = this.cur;
|
|
53
|
+
this.cur = n;
|
|
54
|
+
this.sync?.();
|
|
55
|
+
if (from !== n)
|
|
56
|
+
this.emit('change', { index: n, from });
|
|
57
|
+
}
|
|
58
|
+
mount() {
|
|
59
|
+
// structure first (works without the runtime as a CSS scroll-snap strip)
|
|
60
|
+
let vp = this.querySelector(':scope > .usa-sc-viewport');
|
|
61
|
+
let track = vp?.querySelector(':scope > .usa-sc-track') || null;
|
|
62
|
+
if (!vp || !track) {
|
|
63
|
+
vp = document.createElement('div');
|
|
64
|
+
vp.className = 'usa-sc-viewport';
|
|
65
|
+
track = document.createElement('div');
|
|
66
|
+
track.className = 'usa-sc-track';
|
|
67
|
+
for (const c of Array.from(this.children))
|
|
68
|
+
if (c instanceof HTMLElement && !c.matches('.usa-rt-missing, .usa-sc-ui'))
|
|
69
|
+
track.append(c);
|
|
70
|
+
vp.append(track);
|
|
71
|
+
this.append(vp);
|
|
72
|
+
}
|
|
73
|
+
this.querySelectorAll(':scope > .usa-sc-ui').forEach((x) => x.remove());
|
|
74
|
+
this.slides = Array.from(track.children);
|
|
75
|
+
const N = this.slides.length;
|
|
76
|
+
this.setAttribute('role', 'region');
|
|
77
|
+
this.setAttribute('aria-roledescription', 'carousel');
|
|
78
|
+
this.setAttribute('aria-label', this.str('label', 'Carousel'));
|
|
79
|
+
vp.tabIndex = 0;
|
|
80
|
+
vp.setAttribute('aria-label', `${this.str('label', 'Carousel')} — use the arrow keys`);
|
|
81
|
+
this.style.setProperty('--usa-sc-gap', `${this.num('gap', 16)}px`);
|
|
82
|
+
this.slides.forEach((s, i) => {
|
|
83
|
+
s.setAttribute('role', 'group');
|
|
84
|
+
s.setAttribute('aria-roledescription', 'slide');
|
|
85
|
+
s.setAttribute('aria-label', `${i + 1} of ${N}`);
|
|
86
|
+
});
|
|
87
|
+
const live = document.createElement('p');
|
|
88
|
+
live.className = 'usa-sc-ui usa-sc-live';
|
|
89
|
+
live.setAttribute('aria-live', 'polite');
|
|
90
|
+
this.append(live);
|
|
91
|
+
let prevB = null, nextB = null;
|
|
92
|
+
if (!this.flag('no-controls') && N > 1) {
|
|
93
|
+
const mk = (cls, label, glyph, fn) => {
|
|
94
|
+
const b = document.createElement('button');
|
|
95
|
+
b.type = 'button';
|
|
96
|
+
b.className = `usa-sc-ui usa-sc-nav ${cls}`;
|
|
97
|
+
b.setAttribute('aria-label', label);
|
|
98
|
+
b.textContent = glyph;
|
|
99
|
+
this.listen(b, 'click', fn);
|
|
100
|
+
this.append(b);
|
|
101
|
+
return b;
|
|
102
|
+
};
|
|
103
|
+
prevB = mk('usa-sc-prev', 'Previous slide', '‹', () => this.goTo(this.cur - 1));
|
|
104
|
+
nextB = mk('usa-sc-next', 'Next slide', '›', () => this.goTo(this.cur + 1));
|
|
105
|
+
}
|
|
106
|
+
const dots = [];
|
|
107
|
+
if (!this.flag('no-dots') && N > 1) {
|
|
108
|
+
const nav = document.createElement('div');
|
|
109
|
+
nav.className = 'usa-sc-ui usa-sc-dots';
|
|
110
|
+
nav.setAttribute('role', 'group');
|
|
111
|
+
nav.setAttribute('aria-label', 'Choose a slide');
|
|
112
|
+
this.slides.forEach((_, i) => {
|
|
113
|
+
const d = document.createElement('button');
|
|
114
|
+
d.type = 'button';
|
|
115
|
+
d.className = 'usa-sc-dot';
|
|
116
|
+
d.setAttribute('aria-label', `Go to slide ${i + 1}`);
|
|
117
|
+
this.listen(d, 'click', () => this.goTo(i));
|
|
118
|
+
nav.append(d);
|
|
119
|
+
dots.push(d);
|
|
120
|
+
});
|
|
121
|
+
this.append(nav);
|
|
122
|
+
}
|
|
123
|
+
let announce = false;
|
|
124
|
+
this.sync = () => {
|
|
125
|
+
dots.forEach((d, i) => d.setAttribute('aria-current', String(i === this.cur)));
|
|
126
|
+
if (prevB)
|
|
127
|
+
prevB.disabled = this.cur <= 0;
|
|
128
|
+
if (nextB)
|
|
129
|
+
nextB.disabled = this.cur >= N - 1;
|
|
130
|
+
this.slides.forEach((s, i) => s.toggleAttribute('data-active', i === this.cur));
|
|
131
|
+
if (announce)
|
|
132
|
+
live.textContent = `Slide ${this.cur + 1} of ${N}`;
|
|
133
|
+
};
|
|
134
|
+
this.listen(vp, 'keydown', (e) => {
|
|
135
|
+
const k = e.key;
|
|
136
|
+
const to = k === 'ArrowRight' ? this.cur + 1 : k === 'ArrowLeft' ? this.cur - 1 : k === 'Home' ? 0 : k === 'End' ? N - 1 : null;
|
|
137
|
+
if (to === null)
|
|
138
|
+
return;
|
|
139
|
+
e.preventDefault();
|
|
140
|
+
announce = true;
|
|
141
|
+
this.goTo(to);
|
|
142
|
+
});
|
|
143
|
+
this.listen(this, 'click', (e) => {
|
|
144
|
+
if (e.target?.closest?.('.usa-sc-nav, .usa-sc-dot'))
|
|
145
|
+
announce = true;
|
|
146
|
+
}, { capture: true });
|
|
147
|
+
const DS = runtimeLink.runtimeModule(this, 'drag-snap');
|
|
148
|
+
const start = Math.max(0, Math.min(N - 1, this.num('index', 0)));
|
|
149
|
+
this.cur = start;
|
|
150
|
+
if (!DS) {
|
|
151
|
+
this.sync();
|
|
152
|
+
return;
|
|
153
|
+
}
|
|
154
|
+
this.dataset.ready = '';
|
|
155
|
+
const center = this.str('align', 'center') !== 'start';
|
|
156
|
+
const measure = () => {
|
|
157
|
+
const vw = vp.clientWidth;
|
|
158
|
+
const max = Math.max(0, track.scrollWidth - vw);
|
|
159
|
+
return this.slides.map((s) => {
|
|
160
|
+
const p = -(s.offsetLeft - (center ? (vw - s.offsetWidth) / 2 : 0));
|
|
161
|
+
return center ? p : Math.max(-max, Math.min(0, p));
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
const apply = (p) => (track.style.transform = `translate3d(${p.toFixed(2)}px,0,0)`);
|
|
165
|
+
const ds = DS.createDragSnap(track, {
|
|
166
|
+
axis: 'x',
|
|
167
|
+
snap: measure(),
|
|
168
|
+
reducedMotion: this.reduced,
|
|
169
|
+
onUpdate: apply,
|
|
170
|
+
onSnap: (i) => this.set(i),
|
|
171
|
+
onDragStart: () => this.toggleAttribute('data-dragging', true),
|
|
172
|
+
onDragEnd: () => this.toggleAttribute('data-dragging', false),
|
|
173
|
+
});
|
|
174
|
+
this.ds = ds;
|
|
175
|
+
ds.snapTo(start, false);
|
|
176
|
+
this.set(start);
|
|
177
|
+
this.onCleanup(() => {
|
|
178
|
+
ds.dispose();
|
|
179
|
+
this.ds = null;
|
|
180
|
+
track.style.transform = '';
|
|
181
|
+
});
|
|
182
|
+
const remeasure = () => ds.setSnapPoints(measure());
|
|
183
|
+
this.listen(window, 'resize', remeasure, { passive: true });
|
|
184
|
+
if (typeof ResizeObserver === 'function') {
|
|
185
|
+
const ro = new ResizeObserver(remeasure);
|
|
186
|
+
ro.observe(vp);
|
|
187
|
+
this.onCleanup(() => ro.disconnect());
|
|
188
|
+
}
|
|
189
|
+
// autoplay: paused on hover / focus / press / off screen; never under reduced motion
|
|
190
|
+
const every = this.num('autoplay', 0);
|
|
191
|
+
if (every > 0 && N > 1 && !this.reduced) {
|
|
192
|
+
let hold = 0, seen = true;
|
|
193
|
+
const h = (d) => () => (hold = Math.max(0, hold + d));
|
|
194
|
+
this.listen(this, 'pointerenter', h(1));
|
|
195
|
+
this.listen(this, 'pointerleave', h(-1));
|
|
196
|
+
this.listen(this, 'focusin', h(1));
|
|
197
|
+
this.listen(this, 'focusout', h(-1));
|
|
198
|
+
this.inView((v) => (seen = v));
|
|
199
|
+
const t = setInterval(() => {
|
|
200
|
+
if (!hold && seen && !ds.dragging)
|
|
201
|
+
this.goTo(this.cur + 1 >= N ? 0 : this.cur + 1);
|
|
202
|
+
}, Math.max(1200, every));
|
|
203
|
+
this.onCleanup(() => clearInterval(t));
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
unmount() {
|
|
207
|
+
this.removeAttribute('data-ready');
|
|
208
|
+
this.removeAttribute('data-dragging');
|
|
209
|
+
}
|
|
210
|
+
}
|
|
211
|
+
return UsaSnapCarousel;
|
|
212
|
+
}, { id: 'snap-carousel', text: css });
|
|
213
|
+
}
|
|
214
|
+
|
|
215
|
+
exports.defineSnapCarousel = defineSnapCarousel;
|
|
216
|
+
//# sourceMappingURL=snap-carousel.cjs.map
|