use-scroll-animate 4.3.0 → 4.5.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 +24 -0
- package/dist/chunks/{base-BPG5zvex.js → base-CZiIAMBc.js} +140 -13
- package/dist/chunks/base-CZiIAMBc.js.map +1 -0
- package/dist/chunks/{base-CXx7jZ-o.cjs → base-CxYU2NK_.cjs} +148 -12
- package/dist/chunks/base-CxYU2NK_.cjs.map +1 -0
- package/dist/chunks/{core-LkGRmgES.js → core-CJHJeMI_.js} +2 -2
- package/dist/chunks/{core-LkGRmgES.js.map → core-CJHJeMI_.js.map} +1 -1
- package/dist/chunks/{core-eXX8rB_b.js → core-COi3DrLx.js} +2 -2
- package/dist/chunks/{core-eXX8rB_b.js.map → core-COi3DrLx.js.map} +1 -1
- package/dist/chunks/{core-IaorbTdu.cjs → core-CctNfzuP.cjs} +2 -2
- package/dist/chunks/{core-IaorbTdu.cjs.map → core-CctNfzuP.cjs.map} +1 -1
- package/dist/chunks/{core-BRIIoKeS.cjs → core-HLqH3qkA.cjs} +2 -2
- package/dist/chunks/{core-BRIIoKeS.cjs.map → core-HLqH3qkA.cjs.map} +1 -1
- package/dist/chunks/{spring-BziPsW3r.js → spring-BS5tg6aK.js} +2 -2
- package/dist/chunks/{spring-BziPsW3r.js.map → spring-BS5tg6aK.js.map} +1 -1
- package/dist/chunks/{spring-2OTnYCzm.cjs → spring-Dkpygsuj.cjs} +2 -2
- package/dist/chunks/{spring-2OTnYCzm.cjs.map → spring-Dkpygsuj.cjs.map} +1 -1
- package/dist/chunks/{variants-BNIrn4ch.cjs → variants-CfJzrzMh.cjs} +2 -2
- package/dist/chunks/{variants-BNIrn4ch.cjs.map → variants-CfJzrzMh.cjs.map} +1 -1
- package/dist/chunks/{variants-BVYMcxRv.js → variants-D9n-3x27.js} +2 -2
- package/dist/chunks/{variants-BVYMcxRv.js.map → variants-D9n-3x27.js.map} +1 -1
- package/dist/components/a11y.cjs +239 -0
- package/dist/components/a11y.cjs.map +1 -0
- package/dist/components/a11y.d.cts +120 -0
- package/dist/components/a11y.d.ts +120 -0
- package/dist/components/a11y.js +224 -0
- package/dist/components/a11y.js.map +1 -0
- package/dist/components/angular.cjs +7 -5
- package/dist/components/angular.cjs.map +1 -1
- package/dist/components/angular.js +7 -5
- package/dist/components/angular.js.map +1 -1
- package/dist/components/background.cjs +2 -2
- package/dist/components/background.d.cts +10 -0
- package/dist/components/background.d.ts +10 -0
- package/dist/components/background.js +3 -3
- package/dist/components/cards.cjs +2 -2
- package/dist/components/cards.d.cts +10 -0
- package/dist/components/cards.d.ts +10 -0
- package/dist/components/cards.js +3 -3
- package/dist/components/click.cjs +2 -2
- package/dist/components/click.d.cts +10 -0
- package/dist/components/click.d.ts +10 -0
- package/dist/components/click.js +3 -3
- package/dist/components/depth.cjs +3 -3
- package/dist/components/depth.d.cts +10 -0
- package/dist/components/depth.d.ts +10 -0
- package/dist/components/depth.js +4 -4
- package/dist/components/feedback.cjs +1 -1
- package/dist/components/feedback.d.cts +10 -0
- package/dist/components/feedback.d.ts +10 -0
- package/dist/components/feedback.js +2 -2
- package/dist/components/gesture.cjs +3 -3
- package/dist/components/gesture.d.cts +10 -0
- package/dist/components/gesture.d.ts +10 -0
- package/dist/components/gesture.js +5 -5
- package/dist/components/interaction.cjs +1 -1
- package/dist/components/interaction.d.cts +10 -0
- package/dist/components/interaction.d.ts +10 -0
- package/dist/components/interaction.js +2 -2
- package/dist/components/layout.cjs +1 -1
- package/dist/components/layout.d.cts +10 -0
- package/dist/components/layout.d.ts +10 -0
- package/dist/components/layout.js +2 -2
- package/dist/components/lite.cjs +10398 -0
- package/dist/components/lite.cjs.map +1 -0
- package/dist/components/lite.d.cts +4 -0
- package/dist/components/lite.d.ts +4 -0
- package/dist/components/lite.js +10161 -0
- package/dist/components/lite.js.map +1 -0
- package/dist/components/packs.cjs +1 -1
- package/dist/components/packs.d.cts +10 -0
- package/dist/components/packs.d.ts +10 -0
- package/dist/components/packs.js +2 -2
- package/dist/components/page.cjs +6 -3
- package/dist/components/page.cjs.map +1 -1
- package/dist/components/page.d.cts +10 -0
- package/dist/components/page.d.ts +10 -0
- package/dist/components/page.js +7 -4
- package/dist/components/page.js.map +1 -1
- package/dist/components/perf.cjs +121 -0
- package/dist/components/perf.cjs.map +1 -0
- package/dist/components/perf.d.cts +97 -0
- package/dist/components/perf.d.ts +97 -0
- package/dist/components/perf.js +111 -0
- package/dist/components/perf.js.map +1 -0
- package/dist/components/physics.cjs +2 -2
- package/dist/components/physics.d.cts +10 -0
- package/dist/components/physics.d.ts +10 -0
- package/dist/components/physics.js +4 -4
- package/dist/components/reveal.cjs +1 -1
- package/dist/components/reveal.d.cts +10 -0
- package/dist/components/reveal.d.ts +10 -0
- package/dist/components/reveal.js +2 -2
- package/dist/components/solid.cjs +7 -5
- package/dist/components/solid.cjs.map +1 -1
- package/dist/components/solid.js +7 -5
- package/dist/components/solid.js.map +1 -1
- package/dist/components/svelte.cjs +7 -5
- package/dist/components/svelte.cjs.map +1 -1
- package/dist/components/svelte.js +7 -5
- package/dist/components/svelte.js.map +1 -1
- package/dist/components/svg.cjs +1 -1
- package/dist/components/svg.d.cts +10 -0
- package/dist/components/svg.d.ts +10 -0
- package/dist/components/svg.js +2 -2
- package/dist/components/text.cjs +2 -2
- package/dist/components/text.d.cts +10 -0
- package/dist/components/text.d.ts +10 -0
- package/dist/components/text.js +3 -3
- package/dist/components/timeline.cjs +2 -2
- package/dist/components/timeline.d.cts +10 -0
- package/dist/components/timeline.d.ts +10 -0
- package/dist/components/timeline.js +4 -4
- package/dist/components/transitions.cjs +1 -1
- package/dist/components/transitions.d.cts +10 -0
- package/dist/components/transitions.d.ts +10 -0
- package/dist/components/transitions.js +2 -2
- package/dist/components/ui.cjs +3 -3
- package/dist/components/ui.d.cts +10 -0
- package/dist/components/ui.d.ts +10 -0
- package/dist/components/ui.js +5 -5
- package/dist/components/vue.cjs +7 -5
- package/dist/components/vue.cjs.map +1 -1
- package/dist/components/vue.js +7 -5
- package/dist/components/vue.js.map +1 -1
- package/dist/components/webgl.cjs +1 -1
- package/dist/components/webgl.d.cts +10 -0
- package/dist/components/webgl.d.ts +10 -0
- package/dist/components/webgl.js +2 -2
- package/dist/components.cjs +32 -5
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +176 -2
- package/dist/components.d.ts +176 -2
- package/dist/components.js +9 -7
- 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 +2 -2
- package/dist/index.js +2 -2
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/docs/ROADMAP.md +2 -2
- package/docs/accessibility.md +28 -0
- package/docs/performance.md +24 -0
- package/package.json +31 -1
- package/dist/chunks/base-BPG5zvex.js.map +0 -1
- package/dist/chunks/base-CXx7jZ-o.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -7,6 +7,30 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
7
7
|
|
|
8
8
|
## [Unreleased]
|
|
9
9
|
|
|
10
|
+
## [4.5.0] - 2026-10-08
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
- **Shared rAF scheduler** — every component loop now runs on one `requestAnimationFrame` per frame (batched, ordered; a throwing callback no longer starves the others). New entry `use-scroll-animate/components/perf`: `onFrame(fn)`, `schedulerStats()`.
|
|
14
|
+
- **Animation budget & auto-degrade** — `setAnimationBudget(n)` / `animationBudget()` / `activeAnimations()`; `autoDegrade({ minFps, maxActive, sample, patience, recovery, onChange })` steps motion to `low` and halves the budget while fps drops or too many animations run, restores when frames recover, dispatches `usa:degrade`.
|
|
15
|
+
- **On-demand CSS** — new entry **`use-scroll-animate/components/lite`**: the whole library without inlined CSS; each category's `dist/components/<cat>.css` is linked the first time one of its elements connects. **≈ 62 KB gzip** for everything (vs ≈ 79 KB), CI budget **≤ 70 KB**. `onDemandStyles(base)`, `loadCategoryStyles(cat, base)`, `categoryOf(tag)`, `loadedStyles()`.
|
|
16
|
+
- Showcase: **autoDegrade()** card (Page & app-wide) — stress 120 animations, toggle a budget, watch scheduler stats.
|
|
17
|
+
- Docs: [docs/performance.md](./docs/performance.md).
|
|
18
|
+
|
|
19
|
+
## [4.4.0] - 2026-10-08
|
|
20
|
+
|
|
21
|
+
### Added
|
|
22
|
+
- **Accessibility toolkit** — new entry `use-scroll-animate/components/a11y` (also re-exported from `use-scroll-animate/components`):
|
|
23
|
+
- **Motion-sensitivity levels** `setMotionSensitivity('full' | 'gentle' | 'minimal' | 'static', persist?)`, `restoreMotionSensitivity()`, `getMotionSensitivity()`, `motionAllowed(kind)`, `MOTION_SENSITIVITY`. `gentle` strips spins, zooms, skews and 3D from every component animation (vestibular-safe); `minimal` = fades only; `static` = no animation at all (also stops page CSS animations). `configureComponents({ motionSensitivity })` and `adaptKeyframes(frames, level)` for your own WAAPI code.
|
|
24
|
+
- **Static alternatives** — `STATIC_ALTERNATIVES` documents the static rendering of every category; `staticAlternative(root)` freezes a subtree at its final state.
|
|
25
|
+
- **aria-live conventions** — one shared polite (`role="status"`) and one assertive (`role="alert"`) region; `announce(message, { politeness, dedupe })`, `liveRegion()`.
|
|
26
|
+
- **`auditMotionA11y(root)`** — focusable-in-`aria-hidden`, unnamed widget roles, sliders without `aria-valuenow`, `<img>` without `alt`, assertive regions outside alerts, endless animations without a motion control (WCAG 2.2.2).
|
|
27
|
+
- **Automated a11y regression tests**: every `<usa-*>` element is mounted at all four sensitivity levels and audited (`test/a11y-regression.test.ts`).
|
|
28
|
+
- Showcase: **setMotionSensitivity()** card (Page & app-wide) — replay a spin-zoom entrance at each level, announce, audit the page.
|
|
29
|
+
- Docs: levels, static alternatives, live-region conventions and the audit in [docs/accessibility.md](./docs/accessibility.md).
|
|
30
|
+
|
|
31
|
+
### Fixed
|
|
32
|
+
- `<usa-cursor>` under reduced motion / on touch no longer keeps author content inside its `aria-hidden` host (found by the new audit).
|
|
33
|
+
|
|
10
34
|
## [4.3.0] - 2026-10-08
|
|
11
35
|
|
|
12
36
|
### Added
|
|
@@ -6,8 +6,9 @@
|
|
|
6
6
|
* imported during SSR (Next, Nuxt, Astro…) and in Electron/Tauri preload
|
|
7
7
|
* scripts. Classes are created the first time a `define*()` function runs.
|
|
8
8
|
*/
|
|
9
|
+
const MOTION_SENSITIVITY_LEVELS = ['full', 'gentle', 'minimal', 'static'];
|
|
9
10
|
const MOTION_SCALE = { off: 0, low: 0.6, normal: 1, high: 1.25 };
|
|
10
|
-
const config = { injectStyles: true, reducedMotion: 'user', motionIntensity: 'normal' };
|
|
11
|
+
const config = { injectStyles: true, reducedMotion: 'user', motionIntensity: 'normal', motionSensitivity: 'full' };
|
|
11
12
|
/** Change global component settings (call before `define*()` for `injectStyles`). */
|
|
12
13
|
function configureComponents(options) {
|
|
13
14
|
Object.assign(config, options);
|
|
@@ -15,6 +16,44 @@ function configureComponents(options) {
|
|
|
15
16
|
document.documentElement.style.setProperty('--usa-motion', String(MOTION_SCALE[options.motionIntensity] ?? 1));
|
|
16
17
|
document.documentElement.setAttribute('data-usa-motion', options.motionIntensity);
|
|
17
18
|
}
|
|
19
|
+
if (options.motionSensitivity && typeof document !== 'undefined') {
|
|
20
|
+
if (options.motionSensitivity === 'full')
|
|
21
|
+
document.documentElement.removeAttribute('data-usa-sensitivity');
|
|
22
|
+
else
|
|
23
|
+
document.documentElement.setAttribute('data-usa-sensitivity', options.motionSensitivity);
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
/** The current motion-sensitivity level (v4.4). */
|
|
27
|
+
function getMotionSensitivity() {
|
|
28
|
+
return config.motionSensitivity;
|
|
29
|
+
}
|
|
30
|
+
const VESTIBULAR = /rotate|scale|skew|perspective|matrix3d/;
|
|
31
|
+
/**
|
|
32
|
+
* Adapt keyframes to the sensitivity level: `gentle` drops transforms that
|
|
33
|
+
* spin, zoom or skew (and 3D), `minimal` keeps opacity only, `static` keeps
|
|
34
|
+
* just the final frame. `full` returns them unchanged.
|
|
35
|
+
*/
|
|
36
|
+
function adaptKeyframes(frames, level = config.motionSensitivity) {
|
|
37
|
+
if (level === 'full' || !frames.length)
|
|
38
|
+
return frames;
|
|
39
|
+
if (level === 'static')
|
|
40
|
+
return [frames[frames.length - 1]];
|
|
41
|
+
return frames.map((f) => {
|
|
42
|
+
const out = {};
|
|
43
|
+
for (const [k, v] of Object.entries(f)) {
|
|
44
|
+
if (k === 'offset' || k === 'easing' || k === 'composite')
|
|
45
|
+
out[k] = v;
|
|
46
|
+
else if (level === 'minimal') {
|
|
47
|
+
if (k === 'opacity')
|
|
48
|
+
out[k] = v;
|
|
49
|
+
}
|
|
50
|
+
else if (k === 'rotate' || k === 'scale' || (k === 'transform' && VESTIBULAR.test(String(v))))
|
|
51
|
+
continue;
|
|
52
|
+
else
|
|
53
|
+
out[k] = v;
|
|
54
|
+
}
|
|
55
|
+
return out;
|
|
56
|
+
});
|
|
18
57
|
}
|
|
19
58
|
/** The current global motion intensity. */
|
|
20
59
|
function getMotionIntensity() {
|
|
@@ -27,7 +66,7 @@ function motionScale() {
|
|
|
27
66
|
const canDefine = () => typeof customElements !== 'undefined' && typeof HTMLElement !== 'undefined';
|
|
28
67
|
/** `true` when animations should be reduced (OS setting or `configureComponents`). */
|
|
29
68
|
function prefersReducedMotion() {
|
|
30
|
-
if (config.motionIntensity === 'off')
|
|
69
|
+
if (config.motionIntensity === 'off' || config.motionSensitivity === 'minimal' || config.motionSensitivity === 'static')
|
|
31
70
|
return true;
|
|
32
71
|
if (config.reducedMotion !== 'user')
|
|
33
72
|
return config.reducedMotion === 'reduce';
|
|
@@ -90,6 +129,7 @@ function getBase() {
|
|
|
90
129
|
if (this._connected)
|
|
91
130
|
return;
|
|
92
131
|
this._connected = true;
|
|
132
|
+
styleLoader?.(this.localName);
|
|
93
133
|
// Upgraded while the parser is still inside us (a <script> in <head>
|
|
94
134
|
// defined the element): children/text are not there yet, so wait.
|
|
95
135
|
if (typeof document !== 'undefined' && document.readyState === 'loading' && !this.nextSibling && !this.childNodes.length) {
|
|
@@ -165,14 +205,31 @@ function getBase() {
|
|
|
165
205
|
}
|
|
166
206
|
/** `el.animate()` that returns `null` (and applies the last frame) without WAAPI. */
|
|
167
207
|
motion(el, keyframes, options) {
|
|
168
|
-
if (typeof el.animate !== 'function') {
|
|
208
|
+
if (typeof el.animate !== 'function' || config.motionSensitivity === 'static') {
|
|
209
|
+
applyFrame(el, keyframes[keyframes.length - 1]);
|
|
210
|
+
return null;
|
|
211
|
+
}
|
|
212
|
+
keyframes = adaptKeyframes(keyframes);
|
|
213
|
+
if (active >= maxActive) {
|
|
169
214
|
applyFrame(el, keyframes[keyframes.length - 1]);
|
|
170
215
|
return null;
|
|
171
216
|
}
|
|
172
217
|
const k = motionScale();
|
|
173
218
|
if (k !== 1 && k > 0 && typeof options.duration === 'number')
|
|
174
219
|
options = { ...options, duration: options.duration * k, delay: (options.delay || 0) * k };
|
|
175
|
-
|
|
220
|
+
const a = el.animate(keyframes, options);
|
|
221
|
+
if (options.iterations !== Infinity) {
|
|
222
|
+
active++;
|
|
223
|
+
let done = false;
|
|
224
|
+
const end = () => {
|
|
225
|
+
if (!done) {
|
|
226
|
+
done = true;
|
|
227
|
+
active--;
|
|
228
|
+
}
|
|
229
|
+
};
|
|
230
|
+
a?.finished?.then(end, end);
|
|
231
|
+
}
|
|
232
|
+
return a;
|
|
176
233
|
}
|
|
177
234
|
emit(type, detail) {
|
|
178
235
|
return this.dispatchEvent(new CustomEvent(`usa:${type}`, { detail, bubbles: true, cancelable: true }));
|
|
@@ -216,17 +273,87 @@ function srText(text) {
|
|
|
216
273
|
s.textContent = text;
|
|
217
274
|
return s;
|
|
218
275
|
}
|
|
219
|
-
|
|
220
|
-
|
|
276
|
+
// --- shared rAF scheduler (4.5) ----------------------------------------------
|
|
277
|
+
// Every component loop goes through one requestAnimationFrame per frame
|
|
278
|
+
// instead of one per element: callbacks are batched, run in order, and a
|
|
279
|
+
// throwing callback no longer starves the others (the first error is rethrown).
|
|
280
|
+
const frameQueue = new Map();
|
|
281
|
+
let frameSeq = 1;
|
|
282
|
+
let frameHandle = 0;
|
|
283
|
+
let frameVia = null;
|
|
284
|
+
const frameStats = { frames: 0, callbacks: 0, peak: 0, last: 0 };
|
|
285
|
+
const frameListeners = new Set();
|
|
286
|
+
function flushFrame(t) {
|
|
287
|
+
frameHandle = 0;
|
|
288
|
+
const dt = frameStats.last && t > frameStats.last ? t - frameStats.last : 16.7;
|
|
289
|
+
frameStats.last = t;
|
|
290
|
+
frameStats.frames++;
|
|
291
|
+
const cbs = Array.from(frameQueue.values());
|
|
292
|
+
frameQueue.clear();
|
|
293
|
+
frameStats.callbacks += cbs.length;
|
|
294
|
+
frameStats.peak = Math.max(frameStats.peak, cbs.length);
|
|
295
|
+
let error = null;
|
|
296
|
+
for (const cb of cbs) {
|
|
297
|
+
try {
|
|
298
|
+
cb(t);
|
|
299
|
+
}
|
|
300
|
+
catch (e) {
|
|
301
|
+
error ?? (error = e);
|
|
302
|
+
}
|
|
303
|
+
}
|
|
304
|
+
frameListeners.forEach((fn) => fn(t, dt));
|
|
305
|
+
if (frameListeners.size)
|
|
306
|
+
requestFlush();
|
|
307
|
+
if (error)
|
|
308
|
+
throw error;
|
|
309
|
+
}
|
|
310
|
+
function requestFlush() {
|
|
311
|
+
const native = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : null;
|
|
312
|
+
// A stale handle from a replaced requestAnimationFrame (tests, iframes) is dropped.
|
|
313
|
+
if (frameHandle && frameVia === native)
|
|
314
|
+
return;
|
|
315
|
+
frameVia = native;
|
|
316
|
+
frameHandle = native ? native(flushFrame) : setTimeout(() => flushFrame(now()), 16);
|
|
317
|
+
}
|
|
318
|
+
/** requestAnimationFrame through the shared scheduler (timeout fallback in jsdom / hidden documents). */
|
|
319
|
+
const raf = (cb) => {
|
|
320
|
+
const id = frameSeq++;
|
|
321
|
+
frameQueue.set(id, cb);
|
|
322
|
+
requestFlush();
|
|
323
|
+
return id;
|
|
324
|
+
};
|
|
221
325
|
/** Monotonic time in ms (rAF callback timestamps differ between environments, so loops use this). */
|
|
222
326
|
const now = () => (typeof performance !== 'undefined' ? performance.now() : Date.now());
|
|
223
327
|
const caf = (id) => {
|
|
224
|
-
|
|
225
|
-
cancelAnimationFrame(id);
|
|
226
|
-
else
|
|
227
|
-
clearTimeout(id);
|
|
328
|
+
frameQueue.delete(id);
|
|
228
329
|
};
|
|
229
|
-
/**
|
|
330
|
+
/** Run `fn(time, dt)` every frame on the shared scheduler until the returned function is called. */
|
|
331
|
+
function onFrame(fn) {
|
|
332
|
+
frameListeners.add(fn);
|
|
333
|
+
requestFlush();
|
|
334
|
+
return () => frameListeners.delete(fn);
|
|
335
|
+
}
|
|
336
|
+
/** Scheduler counters: frames flushed, callbacks run, peak callbacks in one frame, pending now. */
|
|
337
|
+
function schedulerStats() {
|
|
338
|
+
return { frames: frameStats.frames, callbacks: frameStats.callbacks, peak: frameStats.peak, pending: frameQueue.size, loops: frameListeners.size };
|
|
339
|
+
}
|
|
340
|
+
// --- active animation budget (4.5) ---------------------------------------------
|
|
341
|
+
let active = 0;
|
|
342
|
+
let maxActive = Infinity;
|
|
343
|
+
/** Number of component animations running right now. */
|
|
344
|
+
const activeAnimations = () => active;
|
|
345
|
+
/** Cap concurrent component animations; extra ones jump to their final frame (`Infinity` = no cap). */
|
|
346
|
+
function setAnimationBudget(max) {
|
|
347
|
+
maxActive = max > 0 ? max : Infinity;
|
|
348
|
+
}
|
|
349
|
+
/** The current cap. */
|
|
350
|
+
const animationBudget = () => maxActive;
|
|
351
|
+
// --- on-demand styles (4.5) -----------------------------------------------------
|
|
352
|
+
let styleLoader = null;
|
|
353
|
+
/** Called with each element's tag the first time one connects (used by the `lite` build to load CSS on demand). */
|
|
354
|
+
function setStyleLoader(fn) {
|
|
355
|
+
styleLoader = fn;
|
|
356
|
+
}
|
|
230
357
|
const EASE_OUT = 'cubic-bezier(0.22, 1, 0.36, 1)';
|
|
231
358
|
const EASE_SPRING = 'cubic-bezier(0.34, 1.56, 0.64, 1)';
|
|
232
359
|
/** Windows Fluent "decelerate" / "point-to-point" curves. */
|
|
@@ -241,5 +368,5 @@ function kindOf(el, valid, fallback) {
|
|
|
241
368
|
}
|
|
242
369
|
const clamp = (v, min, max) => Math.min(max, Math.max(min, v));
|
|
243
370
|
|
|
244
|
-
export { EASE_SPRING as E, FLUENT_DECELERATE as F, MOTION_SCALE as M,
|
|
245
|
-
//# sourceMappingURL=base-
|
|
371
|
+
export { EASE_SPRING as E, FLUENT_DECELERATE as F, MOTION_SCALE as M, MOTION_SENSITIVITY_LEVELS as a, activeAnimations as b, canDefine as c, adaptKeyframes as d, animationBudget as e, configureComponents as f, getMotionIntensity as g, getMotionSensitivity as h, setAnimationBudget as i, clamp as j, caf as k, applyFrame as l, motionScale as m, now as n, onFrame as o, prefersReducedMotion as p, adoptStyles as q, raf as r, schedulerStats as s, setStyleLoader as t, defineElement as u, EASE_OUT as v, kindOf as w, shadowStyles as x, srText as y };
|
|
372
|
+
//# sourceMappingURL=base-CZiIAMBc.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-CZiIAMBc.js","sources":["../../src/components/base.ts"],"sourcesContent":["/**\n * use-scroll-animate/components — shared base for the `<usa-*>` custom elements.\n *\n * Everything here is lazy: nothing touches `window`, `document`,\n * `HTMLElement` or `matchMedia` at import time, so the components can be\n * imported during SSR (Next, Nuxt, Astro…) and in Electron/Tauri preload\n * scripts. Classes are created the first time a `define*()` function runs.\n */\n\nexport interface ComponentsConfig {\n /**\n * Inject each component's CSS when it is defined (default `true`). Uses a\n * constructable stylesheet (`document.adoptedStyleSheets`, which a strict\n * `style-src` CSP does not block) and falls back to a `<style>` tag. Set\n * to `false` when you load `use-scroll-animate/components.css` yourself.\n */\n injectStyles?: boolean;\n /**\n * `'user'` (default) follows `prefers-reduced-motion`; `'reduce'` always\n * uses the reduced variants (e.g. a kiosk / battery-saver mode);\n * `'no-preference'` ignores the OS setting (only for demos — respect your users).\n */\n reducedMotion?: 'user' | 'reduce' | 'no-preference';\n /**\n * Global motion intensity (v2.7): `'off'` (same as reduced motion),\n * `'low'` (shorter, calmer), `'normal'` (default) or `'high'`. Scales every\n * component animation's duration and sets `--usa-motion` (0 / 0.6 / 1 /\n * 1.25) on `<html>` for your own CSS. See `setMotionIntensity()`.\n */\n motionIntensity?: MotionIntensity;\n /**\n * Motion-sensitivity level (v4.4), finer than reduced motion:\n * `'full'` (default) · `'gentle'` (no spins, zooms, skews or parallax —\n * translations and fades only, safe for vestibular disorders) ·\n * `'minimal'` (fades only; components use their reduced-motion variants) ·\n * `'static'` (no animation: every component shows its static alternative).\n * See `setMotionSensitivity()` in `use-scroll-animate/components/a11y`.\n */\n motionSensitivity?: MotionSensitivity;\n}\n\nexport type MotionSensitivity = 'full' | 'gentle' | 'minimal' | 'static';\nexport const MOTION_SENSITIVITY_LEVELS: readonly MotionSensitivity[] = ['full', 'gentle', 'minimal', 'static'];\n\nexport type MotionIntensity = 'off' | 'low' | 'normal' | 'high';\nexport const MOTION_SCALE: Record<MotionIntensity, number> = { off: 0, low: 0.6, normal: 1, high: 1.25 };\n\nconst config: Required<ComponentsConfig> = { injectStyles: true, reducedMotion: 'user', motionIntensity: 'normal', motionSensitivity: 'full' };\n\n/** Change global component settings (call before `define*()` for `injectStyles`). */\nexport function configureComponents(options: ComponentsConfig): void {\n Object.assign(config, options);\n if (options.motionIntensity && typeof document !== 'undefined') {\n document.documentElement.style.setProperty('--usa-motion', String(MOTION_SCALE[options.motionIntensity] ?? 1));\n document.documentElement.setAttribute('data-usa-motion', options.motionIntensity);\n }\n if (options.motionSensitivity && typeof document !== 'undefined') {\n if (options.motionSensitivity === 'full') document.documentElement.removeAttribute('data-usa-sensitivity');\n else document.documentElement.setAttribute('data-usa-sensitivity', options.motionSensitivity);\n }\n}\n\n/** The current motion-sensitivity level (v4.4). */\nexport function getMotionSensitivity(): MotionSensitivity {\n return config.motionSensitivity;\n}\n\nconst VESTIBULAR = /rotate|scale|skew|perspective|matrix3d/;\n/**\n * Adapt keyframes to the sensitivity level: `gentle` drops transforms that\n * spin, zoom or skew (and 3D), `minimal` keeps opacity only, `static` keeps\n * just the final frame. `full` returns them unchanged.\n */\nexport function adaptKeyframes(frames: Keyframe[], level: MotionSensitivity = config.motionSensitivity): Keyframe[] {\n if (level === 'full' || !frames.length) return frames;\n if (level === 'static') return [frames[frames.length - 1]];\n return frames.map((f) => {\n const out: Keyframe = {};\n for (const [k, v] of Object.entries(f)) {\n if (k === 'offset' || k === 'easing' || k === 'composite') out[k] = v as any;\n else if (level === 'minimal') {\n if (k === 'opacity') out[k] = v as any;\n } else if (k === 'rotate' || k === 'scale' || (k === 'transform' && VESTIBULAR.test(String(v)))) continue;\n else out[k] = v as any;\n }\n return out;\n });\n}\n\n/** The current global motion intensity. */\nexport function getMotionIntensity(): MotionIntensity {\n return config.motionIntensity;\n}\n\n/** Duration multiplier for the current intensity (1 when `normal`). */\nexport function motionScale(): number {\n return MOTION_SCALE[config.motionIntensity] ?? 1;\n}\n\nexport const canDefine = (): boolean => typeof customElements !== 'undefined' && typeof HTMLElement !== 'undefined';\n\n/** `true` when animations should be reduced (OS setting or `configureComponents`). */\nexport function prefersReducedMotion(): boolean {\n if (config.motionIntensity === 'off' || config.motionSensitivity === 'minimal' || config.motionSensitivity === 'static') return true;\n if (config.reducedMotion !== 'user') return config.reducedMotion === 'reduce';\n return typeof matchMedia === 'function' && !!matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\nconst injected = new Set<string>();\n\n/** Add a component's stylesheet to the document once. */\nexport function adoptStyles(id: string, css: string): void {\n if (!config.injectStyles || !css || injected.has(id) || typeof document === 'undefined') return;\n injected.add(id);\n try {\n if (typeof CSSStyleSheet === 'function' && 'adoptedStyleSheets' in document) {\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(css);\n document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];\n return;\n }\n } catch {\n /* fall through to <style> */\n }\n const style = document.createElement('style');\n style.setAttribute('data-usa', id);\n style.textContent = css;\n (document.head || document.documentElement).appendChild(style);\n}\n\n/** Attach `css` to a shadow root (constructable sheet where supported, else `<style>`). */\nexport function shadowStyles(root: ShadowRoot, css: string): void {\n try {\n if (typeof CSSStyleSheet === 'function' && 'adoptedStyleSheets' in root) {\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(css);\n root.adoptedStyleSheets = [sheet];\n return;\n }\n } catch {\n /* fall through */\n }\n const style = document.createElement('style');\n style.textContent = css;\n root.prepend(style);\n}\n\nexport type Cleanup = () => void;\n\n/**\n * Members shared by every `<usa-*>` element. Attribute helpers, a cleanup\n * bag that is emptied on disconnect, and motion helpers that degrade to the\n * final state without WAAPI or under reduced motion.\n */\nexport interface UsaElement extends HTMLElement {\n /** `true` while reduced motion applies to this element. */\n readonly reduced: boolean;\n}\n\nexport interface UsaBase extends UsaElement {\n mount(): void;\n changed(name: string): void;\n unmount(): void;\n str(name: string, fallback?: string): string;\n num(name: string, fallback: number): number;\n flag(name: string): boolean;\n setFlag(name: string, on: boolean): void;\n onCleanup(fn: Cleanup): void;\n listen<K extends keyof HTMLElementEventMap>(\n target: EventTarget,\n type: K | string,\n fn: (e: any) => void,\n options?: AddEventListenerOptions\n ): void;\n inView(cb: (visible: boolean, entry?: IntersectionObserverEntry) => void, init?: IntersectionObserverInit, target?: Element): void;\n motion(el: Element, keyframes: Keyframe[], options: KeyframeAnimationOptions): Animation | null;\n emit(type: string, detail?: unknown): boolean;\n}\n\ntype BaseCtor = new () => UsaBase;\nlet baseClass: BaseCtor | null = null;\n\n/** The lazily created base class (needs `HTMLElement`). */\nexport function getBase(): BaseCtor {\n if (baseClass) return baseClass;\n class Base extends HTMLElement {\n private _cleanups: Cleanup[] = [];\n private _connected = false;\n\n get reduced(): boolean {\n return prefersReducedMotion();\n }\n\n connectedCallback(): void {\n if (this._connected) return;\n this._connected = true;\n styleLoader?.(this.localName);\n // Upgraded while the parser is still inside us (a <script> in <head>\n // defined the element): children/text are not there yet, so wait.\n if (typeof document !== 'undefined' && document.readyState === 'loading' && !this.nextSibling && !this.childNodes.length) {\n const go = () => {\n if (this._connected && this.isConnected) this.mount();\n };\n document.addEventListener('DOMContentLoaded', go, { once: true });\n this._cleanups.push(() => document.removeEventListener('DOMContentLoaded', go));\n return;\n }\n this.mount();\n }\n\n disconnectedCallback(): void {\n this._connected = false;\n this.teardown();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, value: string | null): void {\n if (!this._connected || oldValue === value) return;\n this.changed(_name);\n }\n\n /** Re-mount on attribute change (override for finer updates). */\n changed(_name: string): void {\n this.teardown();\n this.mount();\n }\n\n private teardown(): void {\n this._cleanups.splice(0).reverse().forEach((fn) => fn());\n this.unmount();\n }\n\n mount(): void {}\n unmount(): void {}\n\n str(name: string, fallback = ''): string {\n const v = this.getAttribute(name);\n return v === null ? fallback : v;\n }\n\n num(name: string, fallback: number): number {\n const v = this.getAttribute(name);\n const n = v === null || v.trim() === '' ? NaN : Number(v);\n return Number.isFinite(n) ? n : fallback;\n }\n\n /** Boolean attribute: present and not `\"false\"`. */\n flag(name: string): boolean {\n const v = this.getAttribute(name);\n return v !== null && v !== 'false';\n }\n\n setFlag(name: string, on: boolean): void {\n if (on) this.setAttribute(name, '');\n else this.removeAttribute(name);\n }\n\n onCleanup(fn: Cleanup): void {\n this._cleanups.push(fn);\n }\n\n listen(target: EventTarget, type: string, fn: (e: any) => void, options?: AddEventListenerOptions): void {\n target.addEventListener(type, fn, options);\n this.onCleanup(() => target.removeEventListener(type, fn, options));\n }\n\n /** Calls `cb(true/false)` as the element enters / leaves the viewport. */\n inView(cb: (visible: boolean, entry?: IntersectionObserverEntry) => void, init?: IntersectionObserverInit, target: Element = this): void {\n if (typeof IntersectionObserver === 'undefined') {\n cb(true);\n return;\n }\n const io = new IntersectionObserver((entries) => {\n for (const e of entries) cb(e.isIntersecting, e);\n }, init);\n io.observe(target);\n this.onCleanup(() => io.disconnect());\n }\n\n /** `el.animate()` that returns `null` (and applies the last frame) without WAAPI. */\n motion(el: Element, keyframes: Keyframe[], options: KeyframeAnimationOptions): Animation | null {\n if (typeof (el as HTMLElement).animate !== 'function' || config.motionSensitivity === 'static') {\n applyFrame(el as HTMLElement, keyframes[keyframes.length - 1]);\n return null;\n }\n keyframes = adaptKeyframes(keyframes);\n if (active >= maxActive) {\n applyFrame(el as HTMLElement, keyframes[keyframes.length - 1]);\n return null;\n }\n const k = motionScale();\n if (k !== 1 && k > 0 && typeof options.duration === 'number') options = { ...options, duration: options.duration * k, delay: (options.delay || 0) * k };\n const a = (el as HTMLElement).animate(keyframes, options);\n if (options.iterations !== Infinity) {\n active++;\n let done = false;\n const end = () => {\n if (!done) {\n done = true;\n active--;\n }\n };\n a?.finished?.then(end, end);\n }\n return a;\n }\n\n emit(type: string, detail?: unknown): boolean {\n return this.dispatchEvent(new CustomEvent(`usa:${type}`, { detail, bubbles: true, cancelable: true }));\n }\n }\n baseClass = Base as unknown as BaseCtor;\n return baseClass;\n}\n\n/** Write a keyframe's properties as inline styles (no-WAAPI fallback). */\nexport function applyFrame(el: HTMLElement, frame?: Keyframe): void {\n if (!frame) return;\n for (const [k, v] of Object.entries(frame)) {\n if (k === 'offset' || k === 'easing' || k === 'composite' || v == null) continue;\n (el.style as any)[k] = String(v);\n }\n}\n\n/**\n * Register `tag` with the class built by `make(Base)`. Returns the\n * constructor, the already registered one, or `undefined` without DOM.\n */\nexport function defineElement(\n tag: string,\n make: (Base: BaseCtor) => CustomElementConstructor,\n css?: { id: string; text: string }\n): CustomElementConstructor | undefined {\n if (!canDefine()) return undefined;\n adoptStyles('base', BASE_CSS);\n if (css) adoptStyles(css.id, css.text);\n const existing = customElements.get(tag);\n if (existing) return existing;\n const ctor = make(getBase());\n customElements.define(tag, ctor);\n return ctor;\n}\n\nconst BASE_CSS = '.usa-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0}';\n\n/** A visually hidden copy of `text` for screen readers (the animated copy is `aria-hidden`). */\nexport function srText(text: string): HTMLSpanElement {\n const s = document.createElement('span');\n s.className = 'usa-sr';\n s.textContent = text;\n return s;\n}\n\n// --- shared rAF scheduler (4.5) ----------------------------------------------\n// Every component loop goes through one requestAnimationFrame per frame\n// instead of one per element: callbacks are batched, run in order, and a\n// throwing callback no longer starves the others (the first error is rethrown).\nconst frameQueue = new Map<number, FrameRequestCallback>();\nlet frameSeq = 1;\nlet frameHandle: number | ReturnType<typeof setTimeout> | 0 = 0;\nlet frameVia: unknown = null;\nconst frameStats = { frames: 0, callbacks: 0, peak: 0, last: 0 };\nconst frameListeners = new Set<(t: number, dt: number) => void>();\n\nfunction flushFrame(t: number): void {\n frameHandle = 0;\n const dt = frameStats.last && t > frameStats.last ? t - frameStats.last : 16.7;\n frameStats.last = t;\n frameStats.frames++;\n const cbs = Array.from(frameQueue.values());\n frameQueue.clear();\n frameStats.callbacks += cbs.length;\n frameStats.peak = Math.max(frameStats.peak, cbs.length);\n let error: unknown = null;\n for (const cb of cbs) {\n try {\n cb(t);\n } catch (e) {\n error ??= e;\n }\n }\n frameListeners.forEach((fn) => fn(t, dt));\n if (frameListeners.size) requestFlush();\n if (error) throw error;\n}\n\nfunction requestFlush(): void {\n const native = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : null;\n // A stale handle from a replaced requestAnimationFrame (tests, iframes) is dropped.\n if (frameHandle && frameVia === native) return;\n frameVia = native;\n frameHandle = native ? native(flushFrame) : setTimeout(() => flushFrame(now()), 16);\n}\n\n/** requestAnimationFrame through the shared scheduler (timeout fallback in jsdom / hidden documents). */\nexport const raf = (cb: FrameRequestCallback): number => {\n const id = frameSeq++;\n frameQueue.set(id, cb);\n requestFlush();\n return id;\n};\n/** Monotonic time in ms (rAF callback timestamps differ between environments, so loops use this). */\nexport const now = (): number => (typeof performance !== 'undefined' ? performance.now() : Date.now());\nexport const caf = (id: number): void => {\n frameQueue.delete(id);\n};\n\n/** Run `fn(time, dt)` every frame on the shared scheduler until the returned function is called. */\nexport function onFrame(fn: (t: number, dt: number) => void): () => void {\n frameListeners.add(fn);\n requestFlush();\n return () => frameListeners.delete(fn);\n}\n\n/** Scheduler counters: frames flushed, callbacks run, peak callbacks in one frame, pending now. */\nexport function schedulerStats(): { frames: number; callbacks: number; peak: number; pending: number; loops: number } {\n return { frames: frameStats.frames, callbacks: frameStats.callbacks, peak: frameStats.peak, pending: frameQueue.size, loops: frameListeners.size };\n}\n\n// --- active animation budget (4.5) ---------------------------------------------\nlet active = 0;\nlet maxActive = Infinity;\n/** Number of component animations running right now. */\nexport const activeAnimations = (): number => active;\n/** Cap concurrent component animations; extra ones jump to their final frame (`Infinity` = no cap). */\nexport function setAnimationBudget(max: number): void {\n maxActive = max > 0 ? max : Infinity;\n}\n/** The current cap. */\nexport const animationBudget = (): number => maxActive;\n\n// --- on-demand styles (4.5) -----------------------------------------------------\nlet styleLoader: ((tag: string) => void) | null = null;\n/** Called with each element's tag the first time one connects (used by the `lite` build to load CSS on demand). */\nexport function setStyleLoader(fn: ((tag: string) => void) | null): void {\n styleLoader = fn;\n}\n\nexport const EASE_OUT = 'cubic-bezier(0.22, 1, 0.36, 1)';\nexport const EASE_SPRING = 'cubic-bezier(0.34, 1.56, 0.64, 1)';\n/** Windows Fluent \"decelerate\" / \"point-to-point\" curves. */\nexport const FLUENT_DECELERATE = 'cubic-bezier(0.1, 0.9, 0.2, 1)';\n\nconst warned = new Set<string>();\n/** Log a deprecation once per key (console.warn). */\nexport function deprecate(key: string, message: string): void {\n if (warned.has(key)) return;\n warned.add(key);\n if (typeof console !== 'undefined') console.warn(`[use-scroll-animate] ${message}`);\n}\n\n/**\n * The `kind` attribute of `<usa-spinner>`, `<usa-check>`, `<usa-dialog>` and\n * `<usa-acrylic>` (3.0: `variant` only selects a style variant).\n */\nexport function kindOf(el: Element, valid: readonly string[] | Record<string, unknown>, fallback: string): string {\n const k = el.getAttribute('kind');\n return k && (Array.isArray(valid) ? valid.includes(k) : k in (valid as object)) ? k : fallback;\n}\n\nexport const clamp = (v: number, min: number, max: number): number => Math.min(max, Math.max(min, v));\n"],"names":[],"mappings":"AAAA;;;;;;;AAOG;AAmCI,MAAM,yBAAyB,GAAiC,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ;MAGhG,YAAY,GAAoC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI;AAEtG,MAAM,MAAM,GAA+B,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,EAAE;AAE9I;AACM,SAAU,mBAAmB,CAAC,OAAyB,EAAA;AAC3D,IAAA,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC9B,IAAI,OAAO,CAAC,eAAe,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;QAC9D,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,CAAC,cAAc,EAAE,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,CAAC,CAAC;QAC9G,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC,iBAAiB,EAAE,OAAO,CAAC,eAAe,CAAC;IACnF;IACA,IAAI,OAAO,CAAC,iBAAiB,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;AAChE,QAAA,IAAI,OAAO,CAAC,iBAAiB,KAAK,MAAM;AAAE,YAAA,QAAQ,CAAC,eAAe,CAAC,eAAe,CAAC,sBAAsB,CAAC;;YACrG,QAAQ,CAAC,eAAe,CAAC,YAAY,CAAC,sBAAsB,EAAE,OAAO,CAAC,iBAAiB,CAAC;IAC/F;AACF;AAEA;SACgB,oBAAoB,GAAA;IAClC,OAAO,MAAM,CAAC,iBAAiB;AACj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G,CAAC,GAAG,EAAE,CAAC,CAAC;;;;"}
|
|
@@ -8,8 +8,9 @@
|
|
|
8
8
|
* imported during SSR (Next, Nuxt, Astro…) and in Electron/Tauri preload
|
|
9
9
|
* scripts. Classes are created the first time a `define*()` function runs.
|
|
10
10
|
*/
|
|
11
|
+
const MOTION_SENSITIVITY_LEVELS = ['full', 'gentle', 'minimal', 'static'];
|
|
11
12
|
const MOTION_SCALE = { off: 0, low: 0.6, normal: 1, high: 1.25 };
|
|
12
|
-
const config = { injectStyles: true, reducedMotion: 'user', motionIntensity: 'normal' };
|
|
13
|
+
const config = { injectStyles: true, reducedMotion: 'user', motionIntensity: 'normal', motionSensitivity: 'full' };
|
|
13
14
|
/** Change global component settings (call before `define*()` for `injectStyles`). */
|
|
14
15
|
function configureComponents(options) {
|
|
15
16
|
Object.assign(config, options);
|
|
@@ -17,6 +18,44 @@ function configureComponents(options) {
|
|
|
17
18
|
document.documentElement.style.setProperty('--usa-motion', String(MOTION_SCALE[options.motionIntensity] ?? 1));
|
|
18
19
|
document.documentElement.setAttribute('data-usa-motion', options.motionIntensity);
|
|
19
20
|
}
|
|
21
|
+
if (options.motionSensitivity && typeof document !== 'undefined') {
|
|
22
|
+
if (options.motionSensitivity === 'full')
|
|
23
|
+
document.documentElement.removeAttribute('data-usa-sensitivity');
|
|
24
|
+
else
|
|
25
|
+
document.documentElement.setAttribute('data-usa-sensitivity', options.motionSensitivity);
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
/** The current motion-sensitivity level (v4.4). */
|
|
29
|
+
function getMotionSensitivity() {
|
|
30
|
+
return config.motionSensitivity;
|
|
31
|
+
}
|
|
32
|
+
const VESTIBULAR = /rotate|scale|skew|perspective|matrix3d/;
|
|
33
|
+
/**
|
|
34
|
+
* Adapt keyframes to the sensitivity level: `gentle` drops transforms that
|
|
35
|
+
* spin, zoom or skew (and 3D), `minimal` keeps opacity only, `static` keeps
|
|
36
|
+
* just the final frame. `full` returns them unchanged.
|
|
37
|
+
*/
|
|
38
|
+
function adaptKeyframes(frames, level = config.motionSensitivity) {
|
|
39
|
+
if (level === 'full' || !frames.length)
|
|
40
|
+
return frames;
|
|
41
|
+
if (level === 'static')
|
|
42
|
+
return [frames[frames.length - 1]];
|
|
43
|
+
return frames.map((f) => {
|
|
44
|
+
const out = {};
|
|
45
|
+
for (const [k, v] of Object.entries(f)) {
|
|
46
|
+
if (k === 'offset' || k === 'easing' || k === 'composite')
|
|
47
|
+
out[k] = v;
|
|
48
|
+
else if (level === 'minimal') {
|
|
49
|
+
if (k === 'opacity')
|
|
50
|
+
out[k] = v;
|
|
51
|
+
}
|
|
52
|
+
else if (k === 'rotate' || k === 'scale' || (k === 'transform' && VESTIBULAR.test(String(v))))
|
|
53
|
+
continue;
|
|
54
|
+
else
|
|
55
|
+
out[k] = v;
|
|
56
|
+
}
|
|
57
|
+
return out;
|
|
58
|
+
});
|
|
20
59
|
}
|
|
21
60
|
/** The current global motion intensity. */
|
|
22
61
|
function getMotionIntensity() {
|
|
@@ -29,7 +68,7 @@ function motionScale() {
|
|
|
29
68
|
const canDefine = () => typeof customElements !== 'undefined' && typeof HTMLElement !== 'undefined';
|
|
30
69
|
/** `true` when animations should be reduced (OS setting or `configureComponents`). */
|
|
31
70
|
function prefersReducedMotion() {
|
|
32
|
-
if (config.motionIntensity === 'off')
|
|
71
|
+
if (config.motionIntensity === 'off' || config.motionSensitivity === 'minimal' || config.motionSensitivity === 'static')
|
|
33
72
|
return true;
|
|
34
73
|
if (config.reducedMotion !== 'user')
|
|
35
74
|
return config.reducedMotion === 'reduce';
|
|
@@ -92,6 +131,7 @@ function getBase() {
|
|
|
92
131
|
if (this._connected)
|
|
93
132
|
return;
|
|
94
133
|
this._connected = true;
|
|
134
|
+
styleLoader?.(this.localName);
|
|
95
135
|
// Upgraded while the parser is still inside us (a <script> in <head>
|
|
96
136
|
// defined the element): children/text are not there yet, so wait.
|
|
97
137
|
if (typeof document !== 'undefined' && document.readyState === 'loading' && !this.nextSibling && !this.childNodes.length) {
|
|
@@ -167,14 +207,31 @@ function getBase() {
|
|
|
167
207
|
}
|
|
168
208
|
/** `el.animate()` that returns `null` (and applies the last frame) without WAAPI. */
|
|
169
209
|
motion(el, keyframes, options) {
|
|
170
|
-
if (typeof el.animate !== 'function') {
|
|
210
|
+
if (typeof el.animate !== 'function' || config.motionSensitivity === 'static') {
|
|
211
|
+
applyFrame(el, keyframes[keyframes.length - 1]);
|
|
212
|
+
return null;
|
|
213
|
+
}
|
|
214
|
+
keyframes = adaptKeyframes(keyframes);
|
|
215
|
+
if (active >= maxActive) {
|
|
171
216
|
applyFrame(el, keyframes[keyframes.length - 1]);
|
|
172
217
|
return null;
|
|
173
218
|
}
|
|
174
219
|
const k = motionScale();
|
|
175
220
|
if (k !== 1 && k > 0 && typeof options.duration === 'number')
|
|
176
221
|
options = { ...options, duration: options.duration * k, delay: (options.delay || 0) * k };
|
|
177
|
-
|
|
222
|
+
const a = el.animate(keyframes, options);
|
|
223
|
+
if (options.iterations !== Infinity) {
|
|
224
|
+
active++;
|
|
225
|
+
let done = false;
|
|
226
|
+
const end = () => {
|
|
227
|
+
if (!done) {
|
|
228
|
+
done = true;
|
|
229
|
+
active--;
|
|
230
|
+
}
|
|
231
|
+
};
|
|
232
|
+
a?.finished?.then(end, end);
|
|
233
|
+
}
|
|
234
|
+
return a;
|
|
178
235
|
}
|
|
179
236
|
emit(type, detail) {
|
|
180
237
|
return this.dispatchEvent(new CustomEvent(`usa:${type}`, { detail, bubbles: true, cancelable: true }));
|
|
@@ -218,17 +275,87 @@ function srText(text) {
|
|
|
218
275
|
s.textContent = text;
|
|
219
276
|
return s;
|
|
220
277
|
}
|
|
221
|
-
|
|
222
|
-
|
|
278
|
+
// --- shared rAF scheduler (4.5) ----------------------------------------------
|
|
279
|
+
// Every component loop goes through one requestAnimationFrame per frame
|
|
280
|
+
// instead of one per element: callbacks are batched, run in order, and a
|
|
281
|
+
// throwing callback no longer starves the others (the first error is rethrown).
|
|
282
|
+
const frameQueue = new Map();
|
|
283
|
+
let frameSeq = 1;
|
|
284
|
+
let frameHandle = 0;
|
|
285
|
+
let frameVia = null;
|
|
286
|
+
const frameStats = { frames: 0, callbacks: 0, peak: 0, last: 0 };
|
|
287
|
+
const frameListeners = new Set();
|
|
288
|
+
function flushFrame(t) {
|
|
289
|
+
frameHandle = 0;
|
|
290
|
+
const dt = frameStats.last && t > frameStats.last ? t - frameStats.last : 16.7;
|
|
291
|
+
frameStats.last = t;
|
|
292
|
+
frameStats.frames++;
|
|
293
|
+
const cbs = Array.from(frameQueue.values());
|
|
294
|
+
frameQueue.clear();
|
|
295
|
+
frameStats.callbacks += cbs.length;
|
|
296
|
+
frameStats.peak = Math.max(frameStats.peak, cbs.length);
|
|
297
|
+
let error = null;
|
|
298
|
+
for (const cb of cbs) {
|
|
299
|
+
try {
|
|
300
|
+
cb(t);
|
|
301
|
+
}
|
|
302
|
+
catch (e) {
|
|
303
|
+
error ?? (error = e);
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
frameListeners.forEach((fn) => fn(t, dt));
|
|
307
|
+
if (frameListeners.size)
|
|
308
|
+
requestFlush();
|
|
309
|
+
if (error)
|
|
310
|
+
throw error;
|
|
311
|
+
}
|
|
312
|
+
function requestFlush() {
|
|
313
|
+
const native = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : null;
|
|
314
|
+
// A stale handle from a replaced requestAnimationFrame (tests, iframes) is dropped.
|
|
315
|
+
if (frameHandle && frameVia === native)
|
|
316
|
+
return;
|
|
317
|
+
frameVia = native;
|
|
318
|
+
frameHandle = native ? native(flushFrame) : setTimeout(() => flushFrame(now()), 16);
|
|
319
|
+
}
|
|
320
|
+
/** requestAnimationFrame through the shared scheduler (timeout fallback in jsdom / hidden documents). */
|
|
321
|
+
const raf = (cb) => {
|
|
322
|
+
const id = frameSeq++;
|
|
323
|
+
frameQueue.set(id, cb);
|
|
324
|
+
requestFlush();
|
|
325
|
+
return id;
|
|
326
|
+
};
|
|
223
327
|
/** Monotonic time in ms (rAF callback timestamps differ between environments, so loops use this). */
|
|
224
328
|
const now = () => (typeof performance !== 'undefined' ? performance.now() : Date.now());
|
|
225
329
|
const caf = (id) => {
|
|
226
|
-
|
|
227
|
-
cancelAnimationFrame(id);
|
|
228
|
-
else
|
|
229
|
-
clearTimeout(id);
|
|
330
|
+
frameQueue.delete(id);
|
|
230
331
|
};
|
|
231
|
-
/**
|
|
332
|
+
/** Run `fn(time, dt)` every frame on the shared scheduler until the returned function is called. */
|
|
333
|
+
function onFrame(fn) {
|
|
334
|
+
frameListeners.add(fn);
|
|
335
|
+
requestFlush();
|
|
336
|
+
return () => frameListeners.delete(fn);
|
|
337
|
+
}
|
|
338
|
+
/** Scheduler counters: frames flushed, callbacks run, peak callbacks in one frame, pending now. */
|
|
339
|
+
function schedulerStats() {
|
|
340
|
+
return { frames: frameStats.frames, callbacks: frameStats.callbacks, peak: frameStats.peak, pending: frameQueue.size, loops: frameListeners.size };
|
|
341
|
+
}
|
|
342
|
+
// --- active animation budget (4.5) ---------------------------------------------
|
|
343
|
+
let active = 0;
|
|
344
|
+
let maxActive = Infinity;
|
|
345
|
+
/** Number of component animations running right now. */
|
|
346
|
+
const activeAnimations = () => active;
|
|
347
|
+
/** Cap concurrent component animations; extra ones jump to their final frame (`Infinity` = no cap). */
|
|
348
|
+
function setAnimationBudget(max) {
|
|
349
|
+
maxActive = max > 0 ? max : Infinity;
|
|
350
|
+
}
|
|
351
|
+
/** The current cap. */
|
|
352
|
+
const animationBudget = () => maxActive;
|
|
353
|
+
// --- on-demand styles (4.5) -----------------------------------------------------
|
|
354
|
+
let styleLoader = null;
|
|
355
|
+
/** Called with each element's tag the first time one connects (used by the `lite` build to load CSS on demand). */
|
|
356
|
+
function setStyleLoader(fn) {
|
|
357
|
+
styleLoader = fn;
|
|
358
|
+
}
|
|
232
359
|
const EASE_OUT = 'cubic-bezier(0.22, 1, 0.36, 1)';
|
|
233
360
|
const EASE_SPRING = 'cubic-bezier(0.34, 1.56, 0.64, 1)';
|
|
234
361
|
/** Windows Fluent "decelerate" / "point-to-point" curves. */
|
|
@@ -247,7 +374,11 @@ exports.EASE_OUT = EASE_OUT;
|
|
|
247
374
|
exports.EASE_SPRING = EASE_SPRING;
|
|
248
375
|
exports.FLUENT_DECELERATE = FLUENT_DECELERATE;
|
|
249
376
|
exports.MOTION_SCALE = MOTION_SCALE;
|
|
377
|
+
exports.MOTION_SENSITIVITY_LEVELS = MOTION_SENSITIVITY_LEVELS;
|
|
378
|
+
exports.activeAnimations = activeAnimations;
|
|
379
|
+
exports.adaptKeyframes = adaptKeyframes;
|
|
250
380
|
exports.adoptStyles = adoptStyles;
|
|
381
|
+
exports.animationBudget = animationBudget;
|
|
251
382
|
exports.applyFrame = applyFrame;
|
|
252
383
|
exports.caf = caf;
|
|
253
384
|
exports.canDefine = canDefine;
|
|
@@ -255,11 +386,16 @@ exports.clamp = clamp;
|
|
|
255
386
|
exports.configureComponents = configureComponents;
|
|
256
387
|
exports.defineElement = defineElement;
|
|
257
388
|
exports.getMotionIntensity = getMotionIntensity;
|
|
389
|
+
exports.getMotionSensitivity = getMotionSensitivity;
|
|
258
390
|
exports.kindOf = kindOf;
|
|
259
391
|
exports.motionScale = motionScale;
|
|
260
392
|
exports.now = now;
|
|
393
|
+
exports.onFrame = onFrame;
|
|
261
394
|
exports.prefersReducedMotion = prefersReducedMotion;
|
|
262
395
|
exports.raf = raf;
|
|
396
|
+
exports.schedulerStats = schedulerStats;
|
|
397
|
+
exports.setAnimationBudget = setAnimationBudget;
|
|
398
|
+
exports.setStyleLoader = setStyleLoader;
|
|
263
399
|
exports.shadowStyles = shadowStyles;
|
|
264
400
|
exports.srText = srText;
|
|
265
|
-
//# sourceMappingURL=base-
|
|
401
|
+
//# sourceMappingURL=base-CxYU2NK_.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"base-CxYU2NK_.cjs","sources":["../../src/components/base.ts"],"sourcesContent":["/**\n * use-scroll-animate/components — shared base for the `<usa-*>` custom elements.\n *\n * Everything here is lazy: nothing touches `window`, `document`,\n * `HTMLElement` or `matchMedia` at import time, so the components can be\n * imported during SSR (Next, Nuxt, Astro…) and in Electron/Tauri preload\n * scripts. Classes are created the first time a `define*()` function runs.\n */\n\nexport interface ComponentsConfig {\n /**\n * Inject each component's CSS when it is defined (default `true`). Uses a\n * constructable stylesheet (`document.adoptedStyleSheets`, which a strict\n * `style-src` CSP does not block) and falls back to a `<style>` tag. Set\n * to `false` when you load `use-scroll-animate/components.css` yourself.\n */\n injectStyles?: boolean;\n /**\n * `'user'` (default) follows `prefers-reduced-motion`; `'reduce'` always\n * uses the reduced variants (e.g. a kiosk / battery-saver mode);\n * `'no-preference'` ignores the OS setting (only for demos — respect your users).\n */\n reducedMotion?: 'user' | 'reduce' | 'no-preference';\n /**\n * Global motion intensity (v2.7): `'off'` (same as reduced motion),\n * `'low'` (shorter, calmer), `'normal'` (default) or `'high'`. Scales every\n * component animation's duration and sets `--usa-motion` (0 / 0.6 / 1 /\n * 1.25) on `<html>` for your own CSS. See `setMotionIntensity()`.\n */\n motionIntensity?: MotionIntensity;\n /**\n * Motion-sensitivity level (v4.4), finer than reduced motion:\n * `'full'` (default) · `'gentle'` (no spins, zooms, skews or parallax —\n * translations and fades only, safe for vestibular disorders) ·\n * `'minimal'` (fades only; components use their reduced-motion variants) ·\n * `'static'` (no animation: every component shows its static alternative).\n * See `setMotionSensitivity()` in `use-scroll-animate/components/a11y`.\n */\n motionSensitivity?: MotionSensitivity;\n}\n\nexport type MotionSensitivity = 'full' | 'gentle' | 'minimal' | 'static';\nexport const MOTION_SENSITIVITY_LEVELS: readonly MotionSensitivity[] = ['full', 'gentle', 'minimal', 'static'];\n\nexport type MotionIntensity = 'off' | 'low' | 'normal' | 'high';\nexport const MOTION_SCALE: Record<MotionIntensity, number> = { off: 0, low: 0.6, normal: 1, high: 1.25 };\n\nconst config: Required<ComponentsConfig> = { injectStyles: true, reducedMotion: 'user', motionIntensity: 'normal', motionSensitivity: 'full' };\n\n/** Change global component settings (call before `define*()` for `injectStyles`). */\nexport function configureComponents(options: ComponentsConfig): void {\n Object.assign(config, options);\n if (options.motionIntensity && typeof document !== 'undefined') {\n document.documentElement.style.setProperty('--usa-motion', String(MOTION_SCALE[options.motionIntensity] ?? 1));\n document.documentElement.setAttribute('data-usa-motion', options.motionIntensity);\n }\n if (options.motionSensitivity && typeof document !== 'undefined') {\n if (options.motionSensitivity === 'full') document.documentElement.removeAttribute('data-usa-sensitivity');\n else document.documentElement.setAttribute('data-usa-sensitivity', options.motionSensitivity);\n }\n}\n\n/** The current motion-sensitivity level (v4.4). */\nexport function getMotionSensitivity(): MotionSensitivity {\n return config.motionSensitivity;\n}\n\nconst VESTIBULAR = /rotate|scale|skew|perspective|matrix3d/;\n/**\n * Adapt keyframes to the sensitivity level: `gentle` drops transforms that\n * spin, zoom or skew (and 3D), `minimal` keeps opacity only, `static` keeps\n * just the final frame. `full` returns them unchanged.\n */\nexport function adaptKeyframes(frames: Keyframe[], level: MotionSensitivity = config.motionSensitivity): Keyframe[] {\n if (level === 'full' || !frames.length) return frames;\n if (level === 'static') return [frames[frames.length - 1]];\n return frames.map((f) => {\n const out: Keyframe = {};\n for (const [k, v] of Object.entries(f)) {\n if (k === 'offset' || k === 'easing' || k === 'composite') out[k] = v as any;\n else if (level === 'minimal') {\n if (k === 'opacity') out[k] = v as any;\n } else if (k === 'rotate' || k === 'scale' || (k === 'transform' && VESTIBULAR.test(String(v)))) continue;\n else out[k] = v as any;\n }\n return out;\n });\n}\n\n/** The current global motion intensity. */\nexport function getMotionIntensity(): MotionIntensity {\n return config.motionIntensity;\n}\n\n/** Duration multiplier for the current intensity (1 when `normal`). */\nexport function motionScale(): number {\n return MOTION_SCALE[config.motionIntensity] ?? 1;\n}\n\nexport const canDefine = (): boolean => typeof customElements !== 'undefined' && typeof HTMLElement !== 'undefined';\n\n/** `true` when animations should be reduced (OS setting or `configureComponents`). */\nexport function prefersReducedMotion(): boolean {\n if (config.motionIntensity === 'off' || config.motionSensitivity === 'minimal' || config.motionSensitivity === 'static') return true;\n if (config.reducedMotion !== 'user') return config.reducedMotion === 'reduce';\n return typeof matchMedia === 'function' && !!matchMedia('(prefers-reduced-motion: reduce)').matches;\n}\n\nconst injected = new Set<string>();\n\n/** Add a component's stylesheet to the document once. */\nexport function adoptStyles(id: string, css: string): void {\n if (!config.injectStyles || !css || injected.has(id) || typeof document === 'undefined') return;\n injected.add(id);\n try {\n if (typeof CSSStyleSheet === 'function' && 'adoptedStyleSheets' in document) {\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(css);\n document.adoptedStyleSheets = [...document.adoptedStyleSheets, sheet];\n return;\n }\n } catch {\n /* fall through to <style> */\n }\n const style = document.createElement('style');\n style.setAttribute('data-usa', id);\n style.textContent = css;\n (document.head || document.documentElement).appendChild(style);\n}\n\n/** Attach `css` to a shadow root (constructable sheet where supported, else `<style>`). */\nexport function shadowStyles(root: ShadowRoot, css: string): void {\n try {\n if (typeof CSSStyleSheet === 'function' && 'adoptedStyleSheets' in root) {\n const sheet = new CSSStyleSheet();\n sheet.replaceSync(css);\n root.adoptedStyleSheets = [sheet];\n return;\n }\n } catch {\n /* fall through */\n }\n const style = document.createElement('style');\n style.textContent = css;\n root.prepend(style);\n}\n\nexport type Cleanup = () => void;\n\n/**\n * Members shared by every `<usa-*>` element. Attribute helpers, a cleanup\n * bag that is emptied on disconnect, and motion helpers that degrade to the\n * final state without WAAPI or under reduced motion.\n */\nexport interface UsaElement extends HTMLElement {\n /** `true` while reduced motion applies to this element. */\n readonly reduced: boolean;\n}\n\nexport interface UsaBase extends UsaElement {\n mount(): void;\n changed(name: string): void;\n unmount(): void;\n str(name: string, fallback?: string): string;\n num(name: string, fallback: number): number;\n flag(name: string): boolean;\n setFlag(name: string, on: boolean): void;\n onCleanup(fn: Cleanup): void;\n listen<K extends keyof HTMLElementEventMap>(\n target: EventTarget,\n type: K | string,\n fn: (e: any) => void,\n options?: AddEventListenerOptions\n ): void;\n inView(cb: (visible: boolean, entry?: IntersectionObserverEntry) => void, init?: IntersectionObserverInit, target?: Element): void;\n motion(el: Element, keyframes: Keyframe[], options: KeyframeAnimationOptions): Animation | null;\n emit(type: string, detail?: unknown): boolean;\n}\n\ntype BaseCtor = new () => UsaBase;\nlet baseClass: BaseCtor | null = null;\n\n/** The lazily created base class (needs `HTMLElement`). */\nexport function getBase(): BaseCtor {\n if (baseClass) return baseClass;\n class Base extends HTMLElement {\n private _cleanups: Cleanup[] = [];\n private _connected = false;\n\n get reduced(): boolean {\n return prefersReducedMotion();\n }\n\n connectedCallback(): void {\n if (this._connected) return;\n this._connected = true;\n styleLoader?.(this.localName);\n // Upgraded while the parser is still inside us (a <script> in <head>\n // defined the element): children/text are not there yet, so wait.\n if (typeof document !== 'undefined' && document.readyState === 'loading' && !this.nextSibling && !this.childNodes.length) {\n const go = () => {\n if (this._connected && this.isConnected) this.mount();\n };\n document.addEventListener('DOMContentLoaded', go, { once: true });\n this._cleanups.push(() => document.removeEventListener('DOMContentLoaded', go));\n return;\n }\n this.mount();\n }\n\n disconnectedCallback(): void {\n this._connected = false;\n this.teardown();\n }\n\n attributeChangedCallback(_name: string, oldValue: string | null, value: string | null): void {\n if (!this._connected || oldValue === value) return;\n this.changed(_name);\n }\n\n /** Re-mount on attribute change (override for finer updates). */\n changed(_name: string): void {\n this.teardown();\n this.mount();\n }\n\n private teardown(): void {\n this._cleanups.splice(0).reverse().forEach((fn) => fn());\n this.unmount();\n }\n\n mount(): void {}\n unmount(): void {}\n\n str(name: string, fallback = ''): string {\n const v = this.getAttribute(name);\n return v === null ? fallback : v;\n }\n\n num(name: string, fallback: number): number {\n const v = this.getAttribute(name);\n const n = v === null || v.trim() === '' ? NaN : Number(v);\n return Number.isFinite(n) ? n : fallback;\n }\n\n /** Boolean attribute: present and not `\"false\"`. */\n flag(name: string): boolean {\n const v = this.getAttribute(name);\n return v !== null && v !== 'false';\n }\n\n setFlag(name: string, on: boolean): void {\n if (on) this.setAttribute(name, '');\n else this.removeAttribute(name);\n }\n\n onCleanup(fn: Cleanup): void {\n this._cleanups.push(fn);\n }\n\n listen(target: EventTarget, type: string, fn: (e: any) => void, options?: AddEventListenerOptions): void {\n target.addEventListener(type, fn, options);\n this.onCleanup(() => target.removeEventListener(type, fn, options));\n }\n\n /** Calls `cb(true/false)` as the element enters / leaves the viewport. */\n inView(cb: (visible: boolean, entry?: IntersectionObserverEntry) => void, init?: IntersectionObserverInit, target: Element = this): void {\n if (typeof IntersectionObserver === 'undefined') {\n cb(true);\n return;\n }\n const io = new IntersectionObserver((entries) => {\n for (const e of entries) cb(e.isIntersecting, e);\n }, init);\n io.observe(target);\n this.onCleanup(() => io.disconnect());\n }\n\n /** `el.animate()` that returns `null` (and applies the last frame) without WAAPI. */\n motion(el: Element, keyframes: Keyframe[], options: KeyframeAnimationOptions): Animation | null {\n if (typeof (el as HTMLElement).animate !== 'function' || config.motionSensitivity === 'static') {\n applyFrame(el as HTMLElement, keyframes[keyframes.length - 1]);\n return null;\n }\n keyframes = adaptKeyframes(keyframes);\n if (active >= maxActive) {\n applyFrame(el as HTMLElement, keyframes[keyframes.length - 1]);\n return null;\n }\n const k = motionScale();\n if (k !== 1 && k > 0 && typeof options.duration === 'number') options = { ...options, duration: options.duration * k, delay: (options.delay || 0) * k };\n const a = (el as HTMLElement).animate(keyframes, options);\n if (options.iterations !== Infinity) {\n active++;\n let done = false;\n const end = () => {\n if (!done) {\n done = true;\n active--;\n }\n };\n a?.finished?.then(end, end);\n }\n return a;\n }\n\n emit(type: string, detail?: unknown): boolean {\n return this.dispatchEvent(new CustomEvent(`usa:${type}`, { detail, bubbles: true, cancelable: true }));\n }\n }\n baseClass = Base as unknown as BaseCtor;\n return baseClass;\n}\n\n/** Write a keyframe's properties as inline styles (no-WAAPI fallback). */\nexport function applyFrame(el: HTMLElement, frame?: Keyframe): void {\n if (!frame) return;\n for (const [k, v] of Object.entries(frame)) {\n if (k === 'offset' || k === 'easing' || k === 'composite' || v == null) continue;\n (el.style as any)[k] = String(v);\n }\n}\n\n/**\n * Register `tag` with the class built by `make(Base)`. Returns the\n * constructor, the already registered one, or `undefined` without DOM.\n */\nexport function defineElement(\n tag: string,\n make: (Base: BaseCtor) => CustomElementConstructor,\n css?: { id: string; text: string }\n): CustomElementConstructor | undefined {\n if (!canDefine()) return undefined;\n adoptStyles('base', BASE_CSS);\n if (css) adoptStyles(css.id, css.text);\n const existing = customElements.get(tag);\n if (existing) return existing;\n const ctor = make(getBase());\n customElements.define(tag, ctor);\n return ctor;\n}\n\nconst BASE_CSS = '.usa-sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);clip-path:inset(50%);white-space:nowrap;border:0}';\n\n/** A visually hidden copy of `text` for screen readers (the animated copy is `aria-hidden`). */\nexport function srText(text: string): HTMLSpanElement {\n const s = document.createElement('span');\n s.className = 'usa-sr';\n s.textContent = text;\n return s;\n}\n\n// --- shared rAF scheduler (4.5) ----------------------------------------------\n// Every component loop goes through one requestAnimationFrame per frame\n// instead of one per element: callbacks are batched, run in order, and a\n// throwing callback no longer starves the others (the first error is rethrown).\nconst frameQueue = new Map<number, FrameRequestCallback>();\nlet frameSeq = 1;\nlet frameHandle: number | ReturnType<typeof setTimeout> | 0 = 0;\nlet frameVia: unknown = null;\nconst frameStats = { frames: 0, callbacks: 0, peak: 0, last: 0 };\nconst frameListeners = new Set<(t: number, dt: number) => void>();\n\nfunction flushFrame(t: number): void {\n frameHandle = 0;\n const dt = frameStats.last && t > frameStats.last ? t - frameStats.last : 16.7;\n frameStats.last = t;\n frameStats.frames++;\n const cbs = Array.from(frameQueue.values());\n frameQueue.clear();\n frameStats.callbacks += cbs.length;\n frameStats.peak = Math.max(frameStats.peak, cbs.length);\n let error: unknown = null;\n for (const cb of cbs) {\n try {\n cb(t);\n } catch (e) {\n error ??= e;\n }\n }\n frameListeners.forEach((fn) => fn(t, dt));\n if (frameListeners.size) requestFlush();\n if (error) throw error;\n}\n\nfunction requestFlush(): void {\n const native = typeof requestAnimationFrame === 'function' ? requestAnimationFrame : null;\n // A stale handle from a replaced requestAnimationFrame (tests, iframes) is dropped.\n if (frameHandle && frameVia === native) return;\n frameVia = native;\n frameHandle = native ? native(flushFrame) : setTimeout(() => flushFrame(now()), 16);\n}\n\n/** requestAnimationFrame through the shared scheduler (timeout fallback in jsdom / hidden documents). */\nexport const raf = (cb: FrameRequestCallback): number => {\n const id = frameSeq++;\n frameQueue.set(id, cb);\n requestFlush();\n return id;\n};\n/** Monotonic time in ms (rAF callback timestamps differ between environments, so loops use this). */\nexport const now = (): number => (typeof performance !== 'undefined' ? performance.now() : Date.now());\nexport const caf = (id: number): void => {\n frameQueue.delete(id);\n};\n\n/** Run `fn(time, dt)` every frame on the shared scheduler until the returned function is called. */\nexport function onFrame(fn: (t: number, dt: number) => void): () => void {\n frameListeners.add(fn);\n requestFlush();\n return () => frameListeners.delete(fn);\n}\n\n/** Scheduler counters: frames flushed, callbacks run, peak callbacks in one frame, pending now. */\nexport function schedulerStats(): { frames: number; callbacks: number; peak: number; pending: number; loops: number } {\n return { frames: frameStats.frames, callbacks: frameStats.callbacks, peak: frameStats.peak, pending: frameQueue.size, loops: frameListeners.size };\n}\n\n// --- active animation budget (4.5) ---------------------------------------------\nlet active = 0;\nlet maxActive = Infinity;\n/** Number of component animations running right now. */\nexport const activeAnimations = (): number => active;\n/** Cap concurrent component animations; extra ones jump to their final frame (`Infinity` = no cap). */\nexport function setAnimationBudget(max: number): void {\n maxActive = max > 0 ? max : Infinity;\n}\n/** The current cap. */\nexport const animationBudget = (): number => maxActive;\n\n// --- on-demand styles (4.5) -----------------------------------------------------\nlet styleLoader: ((tag: string) => void) | null = null;\n/** Called with each element's tag the first time one connects (used by the `lite` build to load CSS on demand). */\nexport function setStyleLoader(fn: ((tag: string) => void) | null): void {\n styleLoader = fn;\n}\n\nexport const EASE_OUT = 'cubic-bezier(0.22, 1, 0.36, 1)';\nexport const EASE_SPRING = 'cubic-bezier(0.34, 1.56, 0.64, 1)';\n/** Windows Fluent \"decelerate\" / \"point-to-point\" curves. */\nexport const FLUENT_DECELERATE = 'cubic-bezier(0.1, 0.9, 0.2, 1)';\n\nconst warned = new Set<string>();\n/** Log a deprecation once per key (console.warn). */\nexport function deprecate(key: string, message: string): void {\n if (warned.has(key)) return;\n warned.add(key);\n if (typeof console !== 'undefined') console.warn(`[use-scroll-animate] ${message}`);\n}\n\n/**\n * The `kind` attribute of `<usa-spinner>`, `<usa-check>`, `<usa-dialog>` and\n * `<usa-acrylic>` (3.0: `variant` only selects a style variant).\n */\nexport function kindOf(el: Element, valid: readonly string[] | Record<string, unknown>, fallback: string): string {\n const k = el.getAttribute('kind');\n return k && (Array.isArray(valid) ? valid.includes(k) : k in (valid as object)) ? k : fallback;\n}\n\nexport const clamp = (v: number, min: number, max: number): number => Math.min(max, Math.max(min, v));\n"],"names":[],"mappings":";;AAAA;;;;;;;AAOG;AAmCI,MAAM,yBAAyB,GAAiC,CAAC,MAAM,EAAE,QAAQ,EAAE,SAAS,EAAE,QAAQ;MAGhG,YAAY,GAAoC,EAAE,GAAG,EAAE,CAAC,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,CAAC,EAAE,IAAI,EAAE,IAAI;AAEtG,MAAM,MAAM,GAA+B,EAAE,YAAY,EAAE,IAAI,EAAE,aAAa,EAAE,MAAM,EAAE,eAAe,EAAE,QAAQ,EAAE,iBAAiB,EAAE,MAAM,EAAE;AAE9I;AACM,SAAU,mBAAmB,CAAC,OAAyB,EAAA;AAC3D,IAAA,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC;IAC9B,IAAI,OAAO,CAAC,eAAe,IAAI,OAAO,QAAQ,KAAK,WAAW,EAAE;QAC9D,QAAQ,CAAC,eAAe,CAAC,KAAK,CAAC,WAAW,CAAC,cAAc,EAAE,MAAM,CAAC,YAAY,CAAC,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,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O,MAAM,iBAAiB,GAAG;AAUjC;;;AAGG;SACa,MAAM,CAAC,EAAW,EAAE,KAAkD,EAAE,QAAgB,EAAA;IACtG,MAAM,CAAC,GAAG,EAAE,CAAC,YAAY,CAAC,MAAM,CAAC;AACjC,IAAA,OAAO,CAAC,KAAK,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,GAAG,CAAC,IAAK,KAAgB,CAAC,GAAG,CAAC,GAAG,QAAQ;AAChG;AAEO,MAAM,KAAK,GAAG,CAAC,CAAS,EAAE,GAAW,EAAE,GAAW,KAAa,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { p as prefersReducedMotion,
|
|
1
|
+
import { p as prefersReducedMotion, j as clamp, k as caf, l as applyFrame, r as raf, m as motionScale, n as now } from './base-CZiIAMBc.js';
|
|
2
2
|
import { resolveDurationToken, resolveEasingToken } from '../components/tokens.js';
|
|
3
3
|
|
|
4
4
|
/** 4.1: whether `scrub()` can use native ScrollTimeline / ViewTimeline here. */
|
|
@@ -257,4 +257,4 @@ function timeline(options = {}) {
|
|
|
257
257
|
}
|
|
258
258
|
|
|
259
259
|
export { TIMELINE_PRESETS as T, resolvePosition as r, supportsNativeScrub as s, timeline as t };
|
|
260
|
-
//# sourceMappingURL=core-
|
|
260
|
+
//# sourceMappingURL=core-CJHJeMI_.js.map
|