use-scroll-animate 3.8.0 → 4.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +47 -0
- package/README.md +17 -14
- package/README_ja.md +11 -11
- package/README_zh.md +12 -12
- package/dist/chunks/{base-BpROOcey.js → base-ZARFccur.js} +2 -2
- package/dist/chunks/{base-BpROOcey.js.map → base-ZARFccur.js.map} +1 -1
- package/dist/chunks/core-Co-6AL0h.js +218 -0
- package/dist/chunks/core-Co-6AL0h.js.map +1 -0
- package/dist/chunks/{core-uxs3ETou.js → core-DKY-fVzR.js} +2 -2
- package/dist/chunks/{core-uxs3ETou.js.map → core-DKY-fVzR.js.map} +1 -1
- package/dist/chunks/core-DXqZm5Il.cjs +222 -0
- package/dist/chunks/core-DXqZm5Il.cjs.map +1 -0
- package/dist/chunks/{index-tags-BANJ-e4H.js → index-tags-43Xtd01A.js} +3 -2
- package/dist/chunks/index-tags-43Xtd01A.js.map +1 -0
- package/dist/chunks/{index-tags-wbuPiMR6.cjs → index-tags-BQh_uGqH.cjs} +3 -2
- package/dist/chunks/index-tags-BQh_uGqH.cjs.map +1 -0
- package/dist/chunks/{spring-C-fw7_9f.js → spring-E2ickYNI.js} +2 -2
- package/dist/chunks/{spring-C-fw7_9f.js.map → spring-E2ickYNI.js.map} +1 -1
- package/dist/chunks/{variants-CHe1VbSn.js → variants-DvnxvRCM.js} +2 -2
- package/dist/chunks/{variants-CHe1VbSn.js.map → variants-DvnxvRCM.js.map} +1 -1
- package/dist/components/angular.cjs +3 -1
- package/dist/components/angular.cjs.map +1 -1
- package/dist/components/angular.d.cts +29 -17
- package/dist/components/angular.d.ts +29 -17
- package/dist/components/angular.js +7 -5
- package/dist/components/angular.js.map +1 -1
- package/dist/components/background.js +3 -3
- package/dist/components/cards.js +3 -3
- package/dist/components/click.js +3 -3
- package/dist/components/depth.js +4 -4
- package/dist/components/feedback.js +2 -2
- package/dist/components/gesture.js +5 -5
- package/dist/components/interaction.js +2 -2
- package/dist/components/jsx.d.cts +2 -1
- package/dist/components/jsx.d.ts +2 -1
- package/dist/components/layout.js +2 -2
- package/dist/components/lazy.cjs +2 -1
- package/dist/components/lazy.cjs.map +1 -1
- package/dist/components/lazy.d.cts +2 -1
- package/dist/components/lazy.d.ts +2 -1
- package/dist/components/lazy.js +2 -1
- package/dist/components/lazy.js.map +1 -1
- package/dist/components/packs.cjs +194 -0
- package/dist/components/packs.cjs.map +1 -0
- package/dist/components/packs.css +3 -0
- package/dist/components/packs.d.cts +107 -0
- package/dist/components/packs.d.ts +107 -0
- package/dist/components/packs.js +185 -0
- package/dist/components/packs.js.map +1 -0
- package/dist/components/page.js +3 -3
- package/dist/components/physics.js +4 -4
- package/dist/components/react.cjs +2 -2
- package/dist/components/react.cjs.map +1 -1
- package/dist/components/react.d.cts +1 -1
- package/dist/components/react.d.ts +1 -1
- package/dist/components/react.js +2 -2
- package/dist/components/react.js.map +1 -1
- package/dist/components/reveal.js +2 -2
- package/dist/components/solid.cjs +3 -1
- package/dist/components/solid.cjs.map +1 -1
- package/dist/components/solid.d.cts +29 -17
- package/dist/components/solid.d.ts +29 -17
- package/dist/components/solid.js +7 -5
- package/dist/components/solid.js.map +1 -1
- package/dist/components/svelte.cjs +3 -1
- package/dist/components/svelte.cjs.map +1 -1
- package/dist/components/svelte.d.cts +29 -17
- package/dist/components/svelte.d.ts +29 -17
- package/dist/components/svelte.js +7 -5
- package/dist/components/svelte.js.map +1 -1
- package/dist/components/svg.js +2 -2
- package/dist/components/text.js +2 -2
- package/dist/components/timeline.cjs +6 -219
- package/dist/components/timeline.cjs.map +1 -1
- package/dist/components/timeline.js +5 -217
- package/dist/components/timeline.js.map +1 -1
- package/dist/components/transitions.cjs +7 -120
- package/dist/components/transitions.cjs.map +1 -1
- package/dist/components/transitions.css +0 -1
- package/dist/components/transitions.d.cts +5 -32
- package/dist/components/transitions.d.ts +5 -32
- package/dist/components/transitions.js +10 -121
- package/dist/components/transitions.js.map +1 -1
- package/dist/components/ui.js +5 -5
- package/dist/components/vue.cjs +3 -1
- package/dist/components/vue.cjs.map +1 -1
- package/dist/components/vue.d.cts +29 -17
- package/dist/components/vue.d.ts +29 -17
- package/dist/components/vue.js +7 -5
- package/dist/components/vue.js.map +1 -1
- package/dist/components/webgl.js +2 -2
- package/dist/components.cjs +18 -10
- package/dist/components.cjs.map +1 -1
- package/dist/components.css +1 -1
- package/dist/components.d.cts +67 -33
- package/dist/components.d.ts +67 -33
- package/dist/components.js +14 -10
- package/dist/components.js.map +1 -1
- package/dist/components.umd.js +2 -2
- package/dist/components.umd.js.map +1 -1
- package/dist/index.cjs +5 -102
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +72 -30
- package/dist/index.d.ts +72 -30
- package/dist/index.js +4 -103
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/docs/API.md +6 -6
- package/docs/ROADMAP.md +14 -0
- package/docs/components.md +16 -4
- package/docs/migration-from-aos.md +1 -1
- package/docs/migration-from-gsap-scrolltrigger.md +6 -6
- package/docs/upgrading-4.md +65 -0
- package/package.json +13 -2
- package/dist/chunks/index-tags-BANJ-e4H.js.map +0 -1
- package/dist/chunks/index-tags-wbuPiMR6.cjs.map +0 -1
|
@@ -1,219 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { a as configureComponents } from '../chunks/base-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const TIMELINE_PRESETS = {
|
|
6
|
-
fade: [{ opacity: 0 }, { opacity: 1 }],
|
|
7
|
-
'fade-up': [{ opacity: 0, transform: 'translateY(24px)' }, { opacity: 1, transform: 'none' }],
|
|
8
|
-
'fade-down': [{ opacity: 0, transform: 'translateY(-24px)' }, { opacity: 1, transform: 'none' }],
|
|
9
|
-
'fade-left': [{ opacity: 0, transform: 'translateX(24px)' }, { opacity: 1, transform: 'none' }],
|
|
10
|
-
'fade-right': [{ opacity: 0, transform: 'translateX(-24px)' }, { opacity: 1, transform: 'none' }],
|
|
11
|
-
scale: [{ opacity: 0, transform: 'scale(0.85)' }, { opacity: 1, transform: 'none' }],
|
|
12
|
-
blur: [{ opacity: 0, filter: 'blur(12px)' }, { opacity: 1, filter: 'blur(0)' }],
|
|
13
|
-
rotate: [{ opacity: 0, transform: 'rotate(-12deg) scale(0.9)' }, { opacity: 1, transform: 'none' }],
|
|
14
|
-
'clip-up': [{ clipPath: 'inset(100% 0 0 0)' }, { clipPath: 'inset(0 0 0 0)' }],
|
|
15
|
-
'clip-right': [{ clipPath: 'inset(0 100% 0 0)' }, { clipPath: 'inset(0 0 0 0)' }],
|
|
16
|
-
};
|
|
17
|
-
/** Resolve a position against the previous step and labels (pure). */
|
|
18
|
-
function resolvePosition(pos, end, prevStart, labels = {}) {
|
|
19
|
-
if (pos === undefined || pos === '' || pos === '>')
|
|
20
|
-
return end;
|
|
21
|
-
if (typeof pos === 'number')
|
|
22
|
-
return Math.max(0, pos);
|
|
23
|
-
const s = String(pos).trim();
|
|
24
|
-
if (/^-?\d+(\.\d+)?$/.test(s))
|
|
25
|
-
return Math.max(0, Number(s));
|
|
26
|
-
const m = /^(<|>|[A-Za-z_][\w-]*)?\s*(?:([+-])=\s*(\d+(?:\.\d+)?))?$/.exec(s);
|
|
27
|
-
if (!m)
|
|
28
|
-
return end;
|
|
29
|
-
const base = m[1] === '<' ? prevStart : m[1] === '>' || !m[1] ? end : labels[m[1]] ?? end;
|
|
30
|
-
const delta = m[2] ? (m[2] === '-' ? -1 : 1) * Number(m[3]) : 0;
|
|
31
|
-
return Math.max(0, base + delta);
|
|
32
|
-
}
|
|
33
|
-
const toEls = (t) => typeof t === 'string' ? (typeof document === 'undefined' ? [] : Array.from(document.querySelectorAll(t))) : t instanceof Element ? [t] : Array.from(t);
|
|
34
|
-
/**
|
|
35
|
-
* Choreograph animations on one clock: chain, overlap, label, seek, reverse and
|
|
36
|
-
* scrub them with scroll. Built on WAAPI (paused animations driven by one
|
|
37
|
-
* playhead); without WAAPI or under reduced motion it jumps to the end state.
|
|
38
|
-
*
|
|
39
|
-
* @example
|
|
40
|
-
* const tl = timeline({ defaults: { duration: 500 } })
|
|
41
|
-
* .to('.title', 'fade-up')
|
|
42
|
-
* .label('cards')
|
|
43
|
-
* .to('.card', 'scale', { stagger: 80, at: '-=200' })
|
|
44
|
-
* .to('.cta', [{ opacity: 0 }, { opacity: 1 }], { at: 'cards+=400' });
|
|
45
|
-
* tl.play(); // or tl.scrub(document.querySelector('.hero'))
|
|
46
|
-
*/
|
|
47
|
-
function timeline(options = {}) {
|
|
48
|
-
const d = { duration: 600, easing: 'cubic-bezier(0.22, 1, 0.36, 1)', stagger: 0, ...options.defaults };
|
|
49
|
-
const steps = [];
|
|
50
|
-
const cues = [];
|
|
51
|
-
const labels = {};
|
|
52
|
-
let end = 0;
|
|
53
|
-
let prevStart = 0;
|
|
54
|
-
let t = 0;
|
|
55
|
-
let frame = 0;
|
|
56
|
-
let dir = 1;
|
|
57
|
-
let settle;
|
|
58
|
-
let built = false;
|
|
59
|
-
const total = () => Math.max(end, ...cues.map((c) => c.at), 0);
|
|
60
|
-
const build = () => {
|
|
61
|
-
if (built)
|
|
62
|
-
return;
|
|
63
|
-
built = true;
|
|
64
|
-
for (const s of steps) {
|
|
65
|
-
if (typeof s.el.animate !== 'function') {
|
|
66
|
-
s.anim = null;
|
|
67
|
-
continue;
|
|
68
|
-
}
|
|
69
|
-
s.anim = s.el.animate(s.frames, { duration: s.duration, delay: s.start, easing: s.easing, fill: 'both' });
|
|
70
|
-
s.anim.pause();
|
|
71
|
-
}
|
|
72
|
-
};
|
|
73
|
-
const render = (to, from) => {
|
|
74
|
-
build();
|
|
75
|
-
t = clamp(to, 0, total());
|
|
76
|
-
for (const s of steps) {
|
|
77
|
-
if (s.anim)
|
|
78
|
-
s.anim.currentTime = t;
|
|
79
|
-
else
|
|
80
|
-
applyFrame(s.el, s.frames[t >= s.start ? s.frames.length - 1 : 0]);
|
|
81
|
-
}
|
|
82
|
-
for (const c of cues)
|
|
83
|
-
if ((from < c.at && t >= c.at) || (from > c.at && t <= c.at))
|
|
84
|
-
c.fn();
|
|
85
|
-
options.onUpdate?.(total() ? t / total() : 1);
|
|
86
|
-
};
|
|
87
|
-
const stop = () => {
|
|
88
|
-
if (frame)
|
|
89
|
-
caf(frame);
|
|
90
|
-
frame = 0;
|
|
91
|
-
};
|
|
92
|
-
const run = (direction) => {
|
|
93
|
-
stop();
|
|
94
|
-
settle?.();
|
|
95
|
-
dir = direction;
|
|
96
|
-
const target = dir > 0 ? total() : 0;
|
|
97
|
-
const k = motionScale();
|
|
98
|
-
if (prefersReducedMotion() || k === 0 || !total()) {
|
|
99
|
-
render(target, t);
|
|
100
|
-
options.onComplete?.();
|
|
101
|
-
return Promise.resolve();
|
|
102
|
-
}
|
|
103
|
-
const rate = (options.speed ?? 1) / k;
|
|
104
|
-
return new Promise((resolve) => {
|
|
105
|
-
settle = () => { settle = undefined; resolve(); };
|
|
106
|
-
let last = now();
|
|
107
|
-
const loop = () => {
|
|
108
|
-
const n = now();
|
|
109
|
-
const next = t + (n - last) * rate * dir;
|
|
110
|
-
last = n;
|
|
111
|
-
render(next, t);
|
|
112
|
-
if ((dir > 0 && t >= target) || (dir < 0 && t <= 0)) {
|
|
113
|
-
frame = 0;
|
|
114
|
-
options.onComplete?.();
|
|
115
|
-
settle?.();
|
|
116
|
-
return;
|
|
117
|
-
}
|
|
118
|
-
frame = raf(loop);
|
|
119
|
-
};
|
|
120
|
-
frame = raf(loop);
|
|
121
|
-
});
|
|
122
|
-
};
|
|
123
|
-
const api = {
|
|
124
|
-
get duration() { return total(); },
|
|
125
|
-
get labels() { return { ...labels }; },
|
|
126
|
-
get time() { return t; },
|
|
127
|
-
to(target, frames, o = {}) {
|
|
128
|
-
const kf = typeof frames === 'string' ? TIMELINE_PRESETS[frames] || TIMELINE_PRESETS.fade : frames;
|
|
129
|
-
const start = resolvePosition(o.at, end, prevStart, labels);
|
|
130
|
-
const duration = o.duration ?? d.duration;
|
|
131
|
-
const stagger = o.stagger ?? d.stagger;
|
|
132
|
-
let last = start;
|
|
133
|
-
toEls(target).forEach((el, i) => {
|
|
134
|
-
const s = start + i * stagger;
|
|
135
|
-
steps.push({ el, frames: kf, start: s, duration, easing: o.easing ?? d.easing });
|
|
136
|
-
last = Math.max(last, s + duration);
|
|
137
|
-
});
|
|
138
|
-
prevStart = start;
|
|
139
|
-
end = Math.max(end, last);
|
|
140
|
-
built = false;
|
|
141
|
-
steps.forEach((s) => s.anim?.cancel());
|
|
142
|
-
return api;
|
|
143
|
-
},
|
|
144
|
-
label(name, at) {
|
|
145
|
-
labels[name] = resolvePosition(at, end, prevStart, labels);
|
|
146
|
-
return api;
|
|
147
|
-
},
|
|
148
|
-
call(fn, at) {
|
|
149
|
-
cues.push({ fn, at: resolvePosition(at, end, prevStart, labels) });
|
|
150
|
-
return api;
|
|
151
|
-
},
|
|
152
|
-
play(from) {
|
|
153
|
-
if (from !== undefined)
|
|
154
|
-
render(resolvePosition(from, 0, 0, labels), t);
|
|
155
|
-
else if (t >= total())
|
|
156
|
-
render(0, -1);
|
|
157
|
-
return run(1);
|
|
158
|
-
},
|
|
159
|
-
reverse() {
|
|
160
|
-
return run(-1);
|
|
161
|
-
},
|
|
162
|
-
pause() {
|
|
163
|
-
stop();
|
|
164
|
-
return api;
|
|
165
|
-
},
|
|
166
|
-
seek(to) {
|
|
167
|
-
stop();
|
|
168
|
-
render(resolvePosition(to, 0, 0, labels), t);
|
|
169
|
-
return api;
|
|
170
|
-
},
|
|
171
|
-
progress(p) {
|
|
172
|
-
if (p !== undefined)
|
|
173
|
-
api.seek(clamp(p, 0, 1) * total());
|
|
174
|
-
return total() ? t / total() : 0;
|
|
175
|
-
},
|
|
176
|
-
scrub(source, o = {}) {
|
|
177
|
-
stop();
|
|
178
|
-
if (prefersReducedMotion() || typeof window === 'undefined') {
|
|
179
|
-
render(total(), t);
|
|
180
|
-
return () => { };
|
|
181
|
-
}
|
|
182
|
-
let id = 0;
|
|
183
|
-
let cur = t;
|
|
184
|
-
const update = () => {
|
|
185
|
-
id = 0;
|
|
186
|
-
const r = source.getBoundingClientRect();
|
|
187
|
-
const vh = window.innerHeight || 1;
|
|
188
|
-
const p = clamp((vh + (o.offset ?? 0) - r.top) / (vh + r.height || 1), 0, 1);
|
|
189
|
-
const goal = p * total();
|
|
190
|
-
const sm = clamp(o.smooth ?? 0, 0, 0.95);
|
|
191
|
-
cur = sm ? cur + (goal - cur) * (1 - sm) : goal;
|
|
192
|
-
render(cur, t);
|
|
193
|
-
if (sm && Math.abs(goal - cur) > 0.5)
|
|
194
|
-
id = raf(update);
|
|
195
|
-
};
|
|
196
|
-
const onScroll = () => { if (!id)
|
|
197
|
-
id = raf(update); };
|
|
198
|
-
window.addEventListener('scroll', onScroll, { passive: true });
|
|
199
|
-
window.addEventListener('resize', onScroll, { passive: true });
|
|
200
|
-
update();
|
|
201
|
-
return () => {
|
|
202
|
-
window.removeEventListener('scroll', onScroll);
|
|
203
|
-
window.removeEventListener('resize', onScroll);
|
|
204
|
-
if (id)
|
|
205
|
-
caf(id);
|
|
206
|
-
};
|
|
207
|
-
},
|
|
208
|
-
cancel() {
|
|
209
|
-
stop();
|
|
210
|
-
settle?.();
|
|
211
|
-
steps.forEach((s) => s.anim?.cancel());
|
|
212
|
-
built = false;
|
|
213
|
-
},
|
|
214
|
-
};
|
|
215
|
-
return api;
|
|
216
|
-
}
|
|
1
|
+
import { h as defineElement } from '../chunks/base-ZARFccur.js';
|
|
2
|
+
export { a as configureComponents, p as prefersReducedMotion } from '../chunks/base-ZARFccur.js';
|
|
3
|
+
import { t as timeline, T as TIMELINE_PRESETS } from '../chunks/core-Co-6AL0h.js';
|
|
4
|
+
export { r as resolvePosition } from '../chunks/core-Co-6AL0h.js';
|
|
217
5
|
|
|
218
6
|
var css = "usa-timeline{display:block}usa-timeline[scrub]{position:relative}@media (prefers-reduced-motion:reduce){usa-timeline [data-tl]{opacity:1 !important;transform:none !important;filter:none !important;clip-path:none !important}}";
|
|
219
7
|
|
|
@@ -292,5 +80,5 @@ function defineTimelineComponents() {
|
|
|
292
80
|
defineTimeline();
|
|
293
81
|
}
|
|
294
82
|
|
|
295
|
-
export { TIMELINE_PRESETS, defineTimeline, defineTimelineComponents,
|
|
83
|
+
export { TIMELINE_PRESETS, defineTimeline, defineTimelineComponents, timeline };
|
|
296
84
|
//# sourceMappingURL=timeline.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeline.js","sources":["../../src/components/timeline/core.ts","../../src/components/timeline/timeline-el.ts","../../src/components/timeline/index.ts"],"sourcesContent":["import { prefersReducedMotion, motionScale, applyFrame, raf, caf, now, clamp } from '../base';\n\n/**\n * Where a step starts on a timeline:\n * - a number: absolute time in ms\n * - `'>'` (default): when the previous step ends · `'<'`: when it starts\n * - `'+=200'` / `'-=200'`: after / overlapping the previous end\n * - `'<+=100'`: 100ms after the previous step's start\n * - `'intro'` / `'intro+=150'`: at (or relative to) a label\n */\nexport type TimelinePosition = number | string;\n\nexport interface TimelineStepOptions {\n /** Duration in ms (default: timeline default, 600). */\n duration?: number;\n /** CSS easing (default `cubic-bezier(0.22, 1, 0.36, 1)`). */\n easing?: string;\n /** Start position, see `TimelinePosition`. */\n at?: TimelinePosition;\n /** ms between targets when the selector matches several elements. */\n stagger?: number;\n}\n\nexport interface TimelineOptions {\n /** Defaults for every step. */\n defaults?: Pick<TimelineStepOptions, 'duration' | 'easing' | 'stagger'>;\n /** Playback rate (1 = normal). */\n speed?: number;\n /** Called after `play()` reaches the end (or the start when reversed). */\n onComplete?: () => void;\n /** Called on every frame with progress 0–1. */\n onUpdate?: (progress: number) => void;\n}\n\nexport interface ScrubOptions {\n /** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts. */\n offset?: number;\n /** Smoothing 0–1 (0 = immediate, default 0). */\n smooth?: number;\n}\n\nexport interface Timeline {\n /** Total length in ms. */\n readonly duration: number;\n /** Label positions in ms. */\n readonly labels: Readonly<Record<string, number>>;\n /** Current playhead in ms. */\n readonly time: number;\n /** Add a step: animate `target` with keyframes or a preset name (`fade-up`, `scale`…). */\n to(target: string | Element | Element[] | NodeList, frames: Keyframe[] | string, options?: TimelineStepOptions): Timeline;\n /** Name a position (default: the current end). */\n label(name: string, at?: TimelinePosition): Timeline;\n /** Run `fn` when the playhead passes `at`. */\n call(fn: () => void, at?: TimelinePosition): Timeline;\n /** Play forwards from the playhead (from 0 when at the end). Resolves at the end. */\n play(from?: TimelinePosition): Promise<void>;\n /** Play backwards to 0. */\n reverse(): Promise<void>;\n pause(): Timeline;\n /** Jump to a time (ms) or label. */\n seek(to: TimelinePosition): Timeline;\n /** Get or set progress 0–1. */\n progress(p?: number): number;\n /** Tie progress to the scroll position of `source` (it moves through the viewport). Returns a stop function. */\n scrub(source: Element, options?: ScrubOptions): () => void;\n /** Stop and drop every animation (elements keep their last frame). */\n cancel(): void;\n}\n\n/** Keyframe presets usable by name in `to()` and `data-tl`. */\nexport const TIMELINE_PRESETS: Record<string, Keyframe[]> = {\n fade: [{ opacity: 0 }, { opacity: 1 }],\n 'fade-up': [{ opacity: 0, transform: 'translateY(24px)' }, { opacity: 1, transform: 'none' }],\n 'fade-down': [{ opacity: 0, transform: 'translateY(-24px)' }, { opacity: 1, transform: 'none' }],\n 'fade-left': [{ opacity: 0, transform: 'translateX(24px)' }, { opacity: 1, transform: 'none' }],\n 'fade-right': [{ opacity: 0, transform: 'translateX(-24px)' }, { opacity: 1, transform: 'none' }],\n scale: [{ opacity: 0, transform: 'scale(0.85)' }, { opacity: 1, transform: 'none' }],\n blur: [{ opacity: 0, filter: 'blur(12px)' }, { opacity: 1, filter: 'blur(0)' }],\n rotate: [{ opacity: 0, transform: 'rotate(-12deg) scale(0.9)' }, { opacity: 1, transform: 'none' }],\n 'clip-up': [{ clipPath: 'inset(100% 0 0 0)' }, { clipPath: 'inset(0 0 0 0)' }],\n 'clip-right': [{ clipPath: 'inset(0 100% 0 0)' }, { clipPath: 'inset(0 0 0 0)' }],\n};\n\n/** Resolve a position against the previous step and labels (pure). */\nexport function resolvePosition(\n pos: TimelinePosition | undefined,\n end: number,\n prevStart: number,\n labels: Record<string, number> = {}\n): number {\n if (pos === undefined || pos === '' || pos === '>') return end;\n if (typeof pos === 'number') return Math.max(0, pos);\n const s = String(pos).trim();\n if (/^-?\\d+(\\.\\d+)?$/.test(s)) return Math.max(0, Number(s));\n const m = /^(<|>|[A-Za-z_][\\w-]*)?\\s*(?:([+-])=\\s*(\\d+(?:\\.\\d+)?))?$/.exec(s);\n if (!m) return end;\n const base = m[1] === '<' ? prevStart : m[1] === '>' || !m[1] ? end : labels[m[1]] ?? end;\n const delta = m[2] ? (m[2] === '-' ? -1 : 1) * Number(m[3]) : 0;\n return Math.max(0, base + delta);\n}\n\nconst toEls = (t: string | Element | Element[] | NodeList): Element[] =>\n typeof t === 'string' ? (typeof document === 'undefined' ? [] : Array.from(document.querySelectorAll(t))) : t instanceof Element ? [t] : Array.from(t as ArrayLike<Element>);\n\ninterface Step { el: Element; frames: Keyframe[]; start: number; duration: number; easing: string; anim?: Animation | null }\ninterface Cue { fn: () => void; at: number }\n\n/**\n * Choreograph animations on one clock: chain, overlap, label, seek, reverse and\n * scrub them with scroll. Built on WAAPI (paused animations driven by one\n * playhead); without WAAPI or under reduced motion it jumps to the end state.\n *\n * @example\n * const tl = timeline({ defaults: { duration: 500 } })\n * .to('.title', 'fade-up')\n * .label('cards')\n * .to('.card', 'scale', { stagger: 80, at: '-=200' })\n * .to('.cta', [{ opacity: 0 }, { opacity: 1 }], { at: 'cards+=400' });\n * tl.play(); // or tl.scrub(document.querySelector('.hero'))\n */\nexport function timeline(options: TimelineOptions = {}): Timeline {\n const d = { duration: 600, easing: 'cubic-bezier(0.22, 1, 0.36, 1)', stagger: 0, ...options.defaults };\n const steps: Step[] = [];\n const cues: Cue[] = [];\n const labels: Record<string, number> = {};\n let end = 0;\n let prevStart = 0;\n let t = 0;\n let frame = 0;\n let dir = 1;\n let settle: (() => void) | undefined;\n let built = false;\n\n const total = () => Math.max(end, ...cues.map((c) => c.at), 0);\n const build = () => {\n if (built) return;\n built = true;\n for (const s of steps) {\n if (typeof (s.el as HTMLElement).animate !== 'function') { s.anim = null; continue; }\n s.anim = (s.el as HTMLElement).animate(s.frames, { duration: s.duration, delay: s.start, easing: s.easing, fill: 'both' });\n s.anim.pause();\n }\n };\n const render = (to: number, from: number) => {\n build();\n t = clamp(to, 0, total());\n for (const s of steps) {\n if (s.anim) s.anim.currentTime = t;\n else applyFrame(s.el as HTMLElement, s.frames[t >= s.start ? s.frames.length - 1 : 0]);\n }\n for (const c of cues) if ((from < c.at && t >= c.at) || (from > c.at && t <= c.at)) c.fn();\n options.onUpdate?.(total() ? t / total() : 1);\n };\n const stop = () => {\n if (frame) caf(frame);\n frame = 0;\n };\n const run = (direction: number): Promise<void> => {\n stop();\n settle?.();\n dir = direction;\n const target = dir > 0 ? total() : 0;\n const k = motionScale();\n if (prefersReducedMotion() || k === 0 || !total()) {\n render(target, t);\n options.onComplete?.();\n return Promise.resolve();\n }\n const rate = (options.speed ?? 1) / k;\n return new Promise<void>((resolve) => {\n settle = () => { settle = undefined; resolve(); };\n let last = now();\n const loop = () => {\n const n = now();\n const next = t + (n - last) * rate * dir;\n last = n;\n render(next, t);\n if ((dir > 0 && t >= target) || (dir < 0 && t <= 0)) {\n frame = 0;\n options.onComplete?.();\n settle?.();\n return;\n }\n frame = raf(loop);\n };\n frame = raf(loop);\n });\n };\n\n const api: Timeline = {\n get duration() { return total(); },\n get labels() { return { ...labels }; },\n get time() { return t; },\n to(target, frames, o = {}) {\n const kf = typeof frames === 'string' ? TIMELINE_PRESETS[frames] || TIMELINE_PRESETS.fade : frames;\n const start = resolvePosition(o.at, end, prevStart, labels);\n const duration = o.duration ?? d.duration;\n const stagger = o.stagger ?? d.stagger;\n let last = start;\n toEls(target).forEach((el, i) => {\n const s = start + i * stagger;\n steps.push({ el, frames: kf, start: s, duration, easing: o.easing ?? d.easing });\n last = Math.max(last, s + duration);\n });\n prevStart = start;\n end = Math.max(end, last);\n built = false;\n steps.forEach((s) => s.anim?.cancel());\n return api;\n },\n label(name, at) {\n labels[name] = resolvePosition(at, end, prevStart, labels);\n return api;\n },\n call(fn, at) {\n cues.push({ fn, at: resolvePosition(at, end, prevStart, labels) });\n return api;\n },\n play(from) {\n if (from !== undefined) render(resolvePosition(from, 0, 0, labels), t);\n else if (t >= total()) render(0, -1);\n return run(1);\n },\n reverse() {\n return run(-1);\n },\n pause() {\n stop();\n return api;\n },\n seek(to) {\n stop();\n render(resolvePosition(to, 0, 0, labels), t);\n return api;\n },\n progress(p) {\n if (p !== undefined) api.seek(clamp(p, 0, 1) * total());\n return total() ? t / total() : 0;\n },\n scrub(source, o = {}) {\n stop();\n if (prefersReducedMotion() || typeof window === 'undefined') {\n render(total(), t);\n return () => {};\n }\n let id = 0;\n let cur = t;\n const update = () => {\n id = 0;\n const r = source.getBoundingClientRect();\n const vh = window.innerHeight || 1;\n const p = clamp((vh + (o.offset ?? 0) - r.top) / (vh + r.height || 1), 0, 1);\n const goal = p * total();\n const sm = clamp(o.smooth ?? 0, 0, 0.95);\n cur = sm ? cur + (goal - cur) * (1 - sm) : goal;\n render(cur, t);\n if (sm && Math.abs(goal - cur) > 0.5) id = raf(update);\n };\n const onScroll = () => { if (!id) id = raf(update); };\n window.addEventListener('scroll', onScroll, { passive: true });\n window.addEventListener('resize', onScroll, { passive: true });\n update();\n return () => {\n window.removeEventListener('scroll', onScroll);\n window.removeEventListener('resize', onScroll);\n if (id) caf(id);\n };\n },\n cancel() {\n stop();\n settle?.();\n steps.forEach((s) => s.anim?.cancel());\n built = false;\n },\n };\n return api;\n}\n","import { defineElement, type UsaElement } from '../base';\nimport { timeline, TIMELINE_PRESETS, type Timeline } from './core';\nimport css from './timeline.css?raw';\n\n/**\n * `<usa-timeline>` — declarative choreography. Every descendant with\n * `data-tl=\"<preset>\"` becomes a step, in document order; `data-at`\n * (`'-=200'`, `'<'`, `'label+=100'`, ms), `data-duration` and `data-label`\n * fine-tune it.\n *\n * Attributes: `trigger` (`view` default · `click` · `manual`), `scrub`\n * (progress follows scroll instead of playing), `overlap` (ms each step\n * overlaps the previous, default 0), `duration` (600), `stagger` (ms),\n * `repeat` (replay every time it enters the viewport). Methods: `play()`,\n * `reverse()`, `seek(t)`; property `timeline`. Event `usa:complete`.\n * Reduced motion: steps appear in their final state.\n */\nexport interface UsaTimelineElement extends UsaElement {\n readonly timeline: Timeline | null;\n play(): Promise<void>;\n reverse(): Promise<void>;\n seek(to: number | string): void;\n}\n\nexport function defineTimeline(tag = 'usa-timeline'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) =>\n class UsaTimeline extends Base {\n static get observedAttributes(): string[] {\n return ['scrub', 'trigger', 'overlap'];\n }\n private _tl: Timeline | null = null;\n\n get timeline(): Timeline | null {\n return this._tl;\n }\n\n play(): Promise<void> {\n return this._tl ? this._tl.play(0).then(() => void this.emit('complete')) : Promise.resolve();\n }\n\n reverse(): Promise<void> {\n return this._tl ? this._tl.reverse() : Promise.resolve();\n }\n\n seek(to: number | string): void {\n this._tl?.seek(to);\n }\n\n mount(): void {\n const overlap = this.num('overlap', 0);\n const tl = (this._tl = timeline({ defaults: { duration: this.num('duration', 600), stagger: this.num('stagger', 0) } }));\n this.querySelectorAll<HTMLElement>('[data-tl]').forEach((el, i) => {\n if (el.dataset.label) tl.label(el.dataset.label);\n const name = el.dataset.tl || 'fade';\n tl.to(el, TIMELINE_PRESETS[name] ? name : 'fade', {\n at: el.dataset.at ?? (i && overlap ? `-=${overlap}` : undefined),\n duration: el.dataset.duration ? Number(el.dataset.duration) : undefined,\n });\n });\n this.onCleanup(() => tl.cancel());\n if (this.reduced) {\n tl.seek(tl.duration);\n return;\n }\n if (this.flag('scrub')) {\n this.onCleanup(tl.scrub(this, { smooth: 0.2 }));\n return;\n }\n tl.seek(0);\n const trigger = this.str('trigger', 'view');\n if (trigger === 'click') this.listen(this, 'click', () => void this.play());\n else if (trigger === 'view') {\n let played = false;\n this.inView((v) => {\n if (v && (!played || this.flag('repeat'))) {\n played = true;\n void this.play();\n } else if (!v && this.flag('repeat')) tl.seek(0);\n }, { threshold: 0.2 });\n }\n }\n\n unmount(): void {\n this._tl = null;\n }\n },\n { id: 'timeline', text: css }\n );\n}\n","/**\n * use-scroll-animate/components/timeline — choreography (v3.1).\n * `timeline()` chains, overlaps, labels, seeks, reverses and scroll-scrubs\n * WAAPI animations on one playhead; `<usa-timeline>` builds one from\n * `data-tl` children.\n */\nimport { defineTimeline, type UsaTimelineElement } from './timeline-el';\n\nexport { defineTimeline };\nexport { timeline, resolvePosition, TIMELINE_PRESETS } from './core';\nexport type { Timeline, TimelineOptions, TimelineStepOptions, TimelinePosition, ScrubOptions } from './core';\nexport type { UsaTimelineElement };\nexport { configureComponents, prefersReducedMotion } from '../base';\nexport type { ComponentsConfig, UsaElement } from '../base';\n\n/** Register every component of this category under its default tag. */\nexport function defineTimelineComponents(): void {\n defineTimeline();\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'usa-timeline': UsaTimelineElement;\n }\n}\n"],"names":[],"mappings":";;;AAqEA;AACO,MAAM,gBAAgB,GAA+B;AAC1D,IAAA,IAAI,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,CAAC;IACtC,SAAS,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,kBAAkB,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAC7F,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,mBAAmB,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAChG,WAAW,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,kBAAkB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AACtC,IAAA,cAAc,EAAE;AAClB;;;;"}
|
|
1
|
+
{"version":3,"file":"timeline.js","sources":["../../src/components/timeline/timeline-el.ts","../../src/components/timeline/index.ts"],"sourcesContent":["import { defineElement, type UsaElement } from '../base';\nimport { timeline, TIMELINE_PRESETS, type Timeline } from './core';\nimport css from './timeline.css?raw';\n\n/**\n * `<usa-timeline>` — declarative choreography. Every descendant with\n * `data-tl=\"<preset>\"` becomes a step, in document order; `data-at`\n * (`'-=200'`, `'<'`, `'label+=100'`, ms), `data-duration` and `data-label`\n * fine-tune it.\n *\n * Attributes: `trigger` (`view` default · `click` · `manual`), `scrub`\n * (progress follows scroll instead of playing), `overlap` (ms each step\n * overlaps the previous, default 0), `duration` (600), `stagger` (ms),\n * `repeat` (replay every time it enters the viewport). Methods: `play()`,\n * `reverse()`, `seek(t)`; property `timeline`. Event `usa:complete`.\n * Reduced motion: steps appear in their final state.\n */\nexport interface UsaTimelineElement extends UsaElement {\n readonly timeline: Timeline | null;\n play(): Promise<void>;\n reverse(): Promise<void>;\n seek(to: number | string): void;\n}\n\nexport function defineTimeline(tag = 'usa-timeline'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) =>\n class UsaTimeline extends Base {\n static get observedAttributes(): string[] {\n return ['scrub', 'trigger', 'overlap'];\n }\n private _tl: Timeline | null = null;\n\n get timeline(): Timeline | null {\n return this._tl;\n }\n\n play(): Promise<void> {\n return this._tl ? this._tl.play(0).then(() => void this.emit('complete')) : Promise.resolve();\n }\n\n reverse(): Promise<void> {\n return this._tl ? this._tl.reverse() : Promise.resolve();\n }\n\n seek(to: number | string): void {\n this._tl?.seek(to);\n }\n\n mount(): void {\n const overlap = this.num('overlap', 0);\n const tl = (this._tl = timeline({ defaults: { duration: this.num('duration', 600), stagger: this.num('stagger', 0) } }));\n this.querySelectorAll<HTMLElement>('[data-tl]').forEach((el, i) => {\n if (el.dataset.label) tl.label(el.dataset.label);\n const name = el.dataset.tl || 'fade';\n tl.to(el, TIMELINE_PRESETS[name] ? name : 'fade', {\n at: el.dataset.at ?? (i && overlap ? `-=${overlap}` : undefined),\n duration: el.dataset.duration ? Number(el.dataset.duration) : undefined,\n });\n });\n this.onCleanup(() => tl.cancel());\n if (this.reduced) {\n tl.seek(tl.duration);\n return;\n }\n if (this.flag('scrub')) {\n this.onCleanup(tl.scrub(this, { smooth: 0.2 }));\n return;\n }\n tl.seek(0);\n const trigger = this.str('trigger', 'view');\n if (trigger === 'click') this.listen(this, 'click', () => void this.play());\n else if (trigger === 'view') {\n let played = false;\n this.inView((v) => {\n if (v && (!played || this.flag('repeat'))) {\n played = true;\n void this.play();\n } else if (!v && this.flag('repeat')) tl.seek(0);\n }, { threshold: 0.2 });\n }\n }\n\n unmount(): void {\n this._tl = null;\n }\n },\n { id: 'timeline', text: css }\n );\n}\n","/**\n * use-scroll-animate/components/timeline — choreography (v3.1).\n * `timeline()` chains, overlaps, labels, seeks, reverses and scroll-scrubs\n * WAAPI animations on one playhead; `<usa-timeline>` builds one from\n * `data-tl` children.\n */\nimport { defineTimeline, type UsaTimelineElement } from './timeline-el';\n\nexport { defineTimeline };\nexport { timeline, resolvePosition, TIMELINE_PRESETS } from './core';\nexport type { Timeline, TimelineOptions, TimelineStepOptions, TimelinePosition, ScrubOptions } from './core';\nexport type { UsaTimelineElement };\nexport { configureComponents, prefersReducedMotion } from '../base';\nexport type { ComponentsConfig, UsaElement } from '../base';\n\n/** Register every component of this category under its default tag. */\nexport function defineTimelineComponents(): void {\n defineTimeline();\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'usa-timeline': UsaTimelineElement;\n }\n}\n"],"names":[],"mappings":";;;;;;;AAwBM,SAAU,cAAc,CAAC,GAAG,GAAG,cAAc,EAAA;AACjD,IAAA,OAAO,aAAa,CAClB,GAAG,EACH,CAAC,IAAI,KACH,MAAM,WAAY,SAAQ,IAAI,CAAA;AAA9B,QAAA,WAAA,GAAA;;YAIU,IAAA,CAAA,GAAG,GAAoB,IAAI;QAuD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AQ,CAAC,CAAC,EAAE;wBACzC,MAAM,GAAG,IAAI;AACb,wBAAA,KAAK,IAAI,CAAC,IAAI,EAAE;oBAClB;yBAAO,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;AAAE,wBAAA,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AAClD,gBAAA,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;YACxB;QACF;QAEA,OAAO,GAAA;AACL,YAAA,IAAI,CAAC,GAAG,GAAG,IAAI;QACjB;KACD,EACH,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,CAC9B;AACH;;AC1FA;;;;;AAKG;AAUH;SACgB,wBAAwB,GAAA;AACtC,IAAA,cAAc,EAAE;AAClB;;;;"}
|
|
@@ -4,7 +4,7 @@ var base = require('../chunks/base-CXx7jZ-o.cjs');
|
|
|
4
4
|
|
|
5
5
|
var shadowCss = ":host{display:contents}dialog{position:fixed;inset:0;width:100%;height:100%;max-width:none;max-height:none;margin:0;padding:0;border:0;background:transparent;color:inherit;overflow:hidden}dialog:not([open]){display:none}dialog::backdrop{background:transparent}[part=\"backdrop\"]{position:absolute;inset:0;background:var(--usa-dialog-backdrop,rgb(0 0 0 / 0.42))}[part=\"panel\"]{position:absolute;left:50%;top:50%;translate:-50% -50%;box-sizing:border-box;width:min(var(--usa-dialog-width,480px),calc(100vw - 32px));max-height:calc(100vh - 32px);overflow:auto;padding:var(--usa-dialog-padding,24px);border-radius:var(--usa-dialog-radius,12px);background:var(--usa-dialog-bg,Canvas);color:var(--usa-dialog-fg,CanvasText);box-shadow:0 32px 64px -12px rgb(0 0 0 / 0.45),0 0 0 1px rgb(127 127 127 / 0.18)}dialog[data-kind^=\"drawer\"] [part=\"panel\"]{top:0;bottom:0;translate:none;max-height:none;height:100%;border-radius:0;width:min(var(--usa-dialog-width,380px),88vw)}dialog[data-kind=\"drawer-start\"] [part=\"panel\"]{left:0}dialog[data-kind=\"drawer-end\"] [part=\"panel\"]{left:auto;right:0}dialog[data-kind=\"drawer-bottom\"] [part=\"panel\"],dialog[data-kind=\"sheet\"] [part=\"panel\"]{top:auto;bottom:0;left:0;right:0;translate:none;width:100%;height:auto;max-height:85vh;border-radius:var(--usa-dialog-radius,16px) var(--usa-dialog-radius,16px) 0 0}dialog[data-kind=\"sheet\"] [part=\"panel\"]{left:50%;translate:-50% 0;width:min(var(--usa-dialog-width,560px),100vw)}";
|
|
6
6
|
|
|
7
|
-
var css$
|
|
7
|
+
var css$2 = "usa-dialog{display:contents}usa-dialog:not(:defined){display:none}";
|
|
8
8
|
|
|
9
9
|
const FROM = {
|
|
10
10
|
modal: 'scale(0.94)',
|
|
@@ -159,10 +159,10 @@ function defineDialog(tag = 'usa-dialog') {
|
|
|
159
159
|
const b = this._backdrop ? this.motion(this._backdrop, backdrop, { duration, easing: 'linear', fill }) : null;
|
|
160
160
|
return Promise.all([a?.finished, b?.finished].map((p) => p?.catch(() => undefined))).then(() => undefined);
|
|
161
161
|
}
|
|
162
|
-
}, { id: 'dialog', text: css$
|
|
162
|
+
}, { id: 'dialog', text: css$2 });
|
|
163
163
|
}
|
|
164
164
|
|
|
165
|
-
var css$
|
|
165
|
+
var css$1 = "usa-accordion{display:block}usa-accordion>details>summary{cursor:pointer}usa-accordion>details>summary::-webkit-details-marker{display:none}usa-accordion>details>summary{list-style:none;display:flex;align-items:center;justify-content:space-between;gap:1em}usa-accordion>details>summary::after{content:\"\";flex:none;width:0.5em;height:0.5em;border-right:2px solid currentColor;border-bottom:2px solid currentColor;transform:translateY(-25%) rotate(45deg);transition:transform 0.3s cubic-bezier(0.22,1,0.36,1);opacity:0.7}usa-accordion>details[open]:not([data-closing])>summary::after{transform:translateY(25%) rotate(-135deg)}@media (prefers-reduced-motion:reduce){usa-accordion>details>summary::after{transition:none}}";
|
|
166
166
|
|
|
167
167
|
function defineAccordion(tag = 'usa-accordion') {
|
|
168
168
|
return base.defineElement(tag, (Base) => class UsaAccordion extends Base {
|
|
@@ -228,93 +228,7 @@ function defineAccordion(tag = 'usa-accordion') {
|
|
|
228
228
|
d.removeAttribute('data-closing');
|
|
229
229
|
}
|
|
230
230
|
}
|
|
231
|
-
}, { id: 'accordion', text: css$
|
|
232
|
-
}
|
|
233
|
-
|
|
234
|
-
var css$1 = "usa-flip-list{display:block}";
|
|
235
|
-
|
|
236
|
-
function defineFlipList(tag = 'usa-flip-list') {
|
|
237
|
-
return base.defineElement(tag, (Base) => class UsaFlipList extends Base {
|
|
238
|
-
constructor() {
|
|
239
|
-
super(...arguments);
|
|
240
|
-
/** Child positions relative to the host, from the last layout we saw. */
|
|
241
|
-
this._pos = new WeakMap();
|
|
242
|
-
this._manual = false;
|
|
243
|
-
}
|
|
244
|
-
static get observedAttributes() {
|
|
245
|
-
return [];
|
|
246
|
-
}
|
|
247
|
-
snapshot() {
|
|
248
|
-
const host = this.getBoundingClientRect();
|
|
249
|
-
for (const el of Array.from(this.children)) {
|
|
250
|
-
const r = el.getBoundingClientRect();
|
|
251
|
-
this._pos.set(el, { x: r.left - host.left, y: r.top - host.top });
|
|
252
|
-
}
|
|
253
|
-
}
|
|
254
|
-
mount() {
|
|
255
|
-
this.snapshot();
|
|
256
|
-
if (typeof MutationObserver !== 'undefined') {
|
|
257
|
-
const mo = new MutationObserver(() => {
|
|
258
|
-
if (!this._manual)
|
|
259
|
-
this.animateFrom(this._pos);
|
|
260
|
-
});
|
|
261
|
-
mo.observe(this, { childList: true });
|
|
262
|
-
this.onCleanup(() => mo.disconnect());
|
|
263
|
-
}
|
|
264
|
-
if (typeof ResizeObserver !== 'undefined') {
|
|
265
|
-
const ro = new ResizeObserver(() => this.snapshot());
|
|
266
|
-
ro.observe(this);
|
|
267
|
-
this.onCleanup(() => ro.disconnect());
|
|
268
|
-
}
|
|
269
|
-
}
|
|
270
|
-
animateFrom(prev) {
|
|
271
|
-
const off = this.reduced || this.flag('disabled');
|
|
272
|
-
const host = this.getBoundingClientRect();
|
|
273
|
-
const kids = Array.from(this.children);
|
|
274
|
-
const now = kids.map((el) => {
|
|
275
|
-
const r = el.getBoundingClientRect();
|
|
276
|
-
return { x: r.left - host.left, y: r.top - host.top };
|
|
277
|
-
});
|
|
278
|
-
const anims = [];
|
|
279
|
-
const duration = this.num('duration', 420);
|
|
280
|
-
const easing = this.str('easing', base.FLUENT_DECELERATE);
|
|
281
|
-
kids.forEach((el, i) => {
|
|
282
|
-
const before = prev.get(el);
|
|
283
|
-
this._pos.set(el, now[i]);
|
|
284
|
-
if (off || typeof el.animate !== 'function')
|
|
285
|
-
return;
|
|
286
|
-
if (!before) {
|
|
287
|
-
anims.push(el.animate([{ opacity: 0, transform: 'scale(0.92)' }, { opacity: 1, transform: 'none' }], { duration, easing }).finished.catch(() => 0));
|
|
288
|
-
return;
|
|
289
|
-
}
|
|
290
|
-
const dx = before.x - now[i].x;
|
|
291
|
-
const dy = before.y - now[i].y;
|
|
292
|
-
if (Math.abs(dx) < 0.5 && Math.abs(dy) < 0.5)
|
|
293
|
-
return;
|
|
294
|
-
anims.push(el.animate([{ transform: `translate(${dx}px, ${dy}px)` }, { transform: 'none' }], { duration, easing, composite: 'add' }).finished.catch(() => 0));
|
|
295
|
-
});
|
|
296
|
-
return Promise.all(anims).then(() => undefined);
|
|
297
|
-
}
|
|
298
|
-
async flip(mutate) {
|
|
299
|
-
this.snapshot();
|
|
300
|
-
const prev = this._pos;
|
|
301
|
-
this._pos = new WeakMap();
|
|
302
|
-
// Copy the snapshot so the observer does not overwrite it mid-mutation
|
|
303
|
-
for (const el of Array.from(this.children)) {
|
|
304
|
-
const p = prev.get(el);
|
|
305
|
-
if (p)
|
|
306
|
-
this._pos.set(el, p);
|
|
307
|
-
}
|
|
308
|
-
this._manual = true;
|
|
309
|
-
try {
|
|
310
|
-
await mutate();
|
|
311
|
-
}
|
|
312
|
-
finally {
|
|
313
|
-
this._manual = false;
|
|
314
|
-
}
|
|
315
|
-
await this.animateFrom(prev);
|
|
316
|
-
}
|
|
317
|
-
}, { id: 'flip-list', text: css$1 });
|
|
231
|
+
}, { id: 'accordion', text: css$1 });
|
|
318
232
|
}
|
|
319
233
|
|
|
320
234
|
var css = "usa-view-switch{display:grid}usa-view-switch>*{grid-area:1 / 1;min-width:0}usa-view-switch>[hidden]:not([data-leaving]){display:none !important}usa-view-switch>[data-leaving]{display:block;pointer-events:none}";
|
|
@@ -493,51 +407,24 @@ async function flip(targets, mutate, options = {}) {
|
|
|
493
407
|
});
|
|
494
408
|
await Promise.all(anims.map((a) => a.finished.catch(() => undefined)));
|
|
495
409
|
}
|
|
496
|
-
/**
|
|
497
|
-
* Connected (shared-element) animation, like WinUI's
|
|
498
|
-
* `ConnectedAnimationService`: `to` flies from the position and size of
|
|
499
|
-
* `from` into its own place (e.g. a thumbnail opening into a detail view).
|
|
500
|
-
* Call it right after `to` is shown. Transforms only.
|
|
501
|
-
*/
|
|
502
|
-
async function connectedAnimation(from, to, options = {}) {
|
|
503
|
-
if (base.prefersReducedMotion() || typeof to.animate !== 'function')
|
|
504
|
-
return;
|
|
505
|
-
const a = from.getBoundingClientRect();
|
|
506
|
-
const b = to.getBoundingClientRect();
|
|
507
|
-
if (!b.width || !b.height)
|
|
508
|
-
return;
|
|
509
|
-
const hide = options.hideSource !== false && from instanceof HTMLElement;
|
|
510
|
-
const prev = hide ? from.style.visibility : '';
|
|
511
|
-
if (hide)
|
|
512
|
-
from.style.visibility = 'hidden';
|
|
513
|
-
const anim = to.animate([
|
|
514
|
-
{ transformOrigin: '0 0', transform: `translate(${a.left - b.left}px, ${a.top - b.top}px) scale(${a.width / b.width}, ${a.height / b.height})` },
|
|
515
|
-
{ transformOrigin: '0 0', transform: 'none' },
|
|
516
|
-
], { duration: options.duration ?? 480, easing: options.easing ?? base.FLUENT_DECELERATE });
|
|
517
|
-
await anim.finished.catch(() => undefined);
|
|
518
|
-
if (hide)
|
|
519
|
-
from.style.visibility = prev;
|
|
520
|
-
}
|
|
521
410
|
|
|
522
411
|
/**
|
|
523
412
|
* use-scroll-animate/components/transitions — view & layout transitions.
|
|
524
|
-
* `<usa-dialog>`, `<usa-accordion>`, `<usa-
|
|
525
|
-
* and the `viewTransition()
|
|
413
|
+
* `<usa-dialog>`, `<usa-accordion>`, `<usa-view-switch>`
|
|
414
|
+
* and the `viewTransition()` and `flip()` helpers (4.0: `<usa-flip-list>` → `<usa-auto-animate>`,
|
|
415
|
+
* `connectedAnimation()` → `sharedTransition()`, both in `components/layout`).
|
|
526
416
|
*/
|
|
527
417
|
/** Register every component of this category under its default tag. */
|
|
528
418
|
function defineTransitionComponents() {
|
|
529
419
|
defineDialog();
|
|
530
420
|
defineAccordion();
|
|
531
|
-
defineFlipList();
|
|
532
421
|
defineViewSwitch();
|
|
533
422
|
}
|
|
534
423
|
|
|
535
424
|
exports.configureComponents = base.configureComponents;
|
|
536
425
|
exports.prefersReducedMotion = base.prefersReducedMotion;
|
|
537
|
-
exports.connectedAnimation = connectedAnimation;
|
|
538
426
|
exports.defineAccordion = defineAccordion;
|
|
539
427
|
exports.defineDialog = defineDialog;
|
|
540
|
-
exports.defineFlipList = defineFlipList;
|
|
541
428
|
exports.defineTransitionComponents = defineTransitionComponents;
|
|
542
429
|
exports.defineViewSwitch = defineViewSwitch;
|
|
543
430
|
exports.flip = flip;
|