use-scroll-animate 4.4.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.
Files changed (104) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/dist/chunks/{base-BtJDNCB6.js → base-CZiIAMBc.js} +97 -10
  3. package/dist/chunks/base-CZiIAMBc.js.map +1 -0
  4. package/dist/chunks/{base-DE2yzxE7.cjs → base-CxYU2NK_.cjs} +102 -9
  5. package/dist/chunks/base-CxYU2NK_.cjs.map +1 -0
  6. package/dist/chunks/{core-DS1nrx5L.js → core-CJHJeMI_.js} +2 -2
  7. package/dist/chunks/{core-DS1nrx5L.js.map → core-CJHJeMI_.js.map} +1 -1
  8. package/dist/chunks/{core-DX6pdOoY.js → core-COi3DrLx.js} +2 -2
  9. package/dist/chunks/{core-DX6pdOoY.js.map → core-COi3DrLx.js.map} +1 -1
  10. package/dist/chunks/{core-DPYjLqA0.cjs → core-CctNfzuP.cjs} +2 -2
  11. package/dist/chunks/{core-DPYjLqA0.cjs.map → core-CctNfzuP.cjs.map} +1 -1
  12. package/dist/chunks/{core-BC9S2osy.cjs → core-HLqH3qkA.cjs} +2 -2
  13. package/dist/chunks/{core-BC9S2osy.cjs.map → core-HLqH3qkA.cjs.map} +1 -1
  14. package/dist/chunks/{spring-CxRz49Wk.js → spring-BS5tg6aK.js} +2 -2
  15. package/dist/chunks/{spring-CxRz49Wk.js.map → spring-BS5tg6aK.js.map} +1 -1
  16. package/dist/chunks/{spring-hsmgd7ml.cjs → spring-Dkpygsuj.cjs} +2 -2
  17. package/dist/chunks/{spring-hsmgd7ml.cjs.map → spring-Dkpygsuj.cjs.map} +1 -1
  18. package/dist/chunks/{variants-CM2zaG8v.cjs → variants-CfJzrzMh.cjs} +2 -2
  19. package/dist/chunks/{variants-CM2zaG8v.cjs.map → variants-CfJzrzMh.cjs.map} +1 -1
  20. package/dist/chunks/{variants-dD6SbUMR.js → variants-D9n-3x27.js} +2 -2
  21. package/dist/chunks/{variants-dD6SbUMR.js.map → variants-D9n-3x27.js.map} +1 -1
  22. package/dist/components/a11y.cjs +1 -1
  23. package/dist/components/a11y.js +2 -2
  24. package/dist/components/angular.cjs +6 -5
  25. package/dist/components/angular.cjs.map +1 -1
  26. package/dist/components/angular.js +6 -5
  27. package/dist/components/angular.js.map +1 -1
  28. package/dist/components/background.cjs +2 -2
  29. package/dist/components/background.js +3 -3
  30. package/dist/components/cards.cjs +2 -2
  31. package/dist/components/cards.js +3 -3
  32. package/dist/components/click.cjs +2 -2
  33. package/dist/components/click.js +3 -3
  34. package/dist/components/depth.cjs +3 -3
  35. package/dist/components/depth.js +4 -4
  36. package/dist/components/feedback.cjs +1 -1
  37. package/dist/components/feedback.js +2 -2
  38. package/dist/components/gesture.cjs +3 -3
  39. package/dist/components/gesture.js +5 -5
  40. package/dist/components/interaction.cjs +1 -1
  41. package/dist/components/interaction.js +2 -2
  42. package/dist/components/layout.cjs +1 -1
  43. package/dist/components/layout.js +2 -2
  44. package/dist/components/lite.cjs +10398 -0
  45. package/dist/components/lite.cjs.map +1 -0
  46. package/dist/components/lite.d.cts +4 -0
  47. package/dist/components/lite.d.ts +4 -0
  48. package/dist/components/lite.js +10161 -0
  49. package/dist/components/lite.js.map +1 -0
  50. package/dist/components/packs.cjs +1 -1
  51. package/dist/components/packs.js +2 -2
  52. package/dist/components/page.cjs +2 -2
  53. package/dist/components/page.js +3 -3
  54. package/dist/components/perf.cjs +121 -0
  55. package/dist/components/perf.cjs.map +1 -0
  56. package/dist/components/perf.d.cts +97 -0
  57. package/dist/components/perf.d.ts +97 -0
  58. package/dist/components/perf.js +111 -0
  59. package/dist/components/perf.js.map +1 -0
  60. package/dist/components/physics.cjs +2 -2
  61. package/dist/components/physics.js +4 -4
  62. package/dist/components/reveal.cjs +1 -1
  63. package/dist/components/reveal.js +2 -2
  64. package/dist/components/solid.cjs +6 -5
  65. package/dist/components/solid.cjs.map +1 -1
  66. package/dist/components/solid.js +6 -5
  67. package/dist/components/solid.js.map +1 -1
  68. package/dist/components/svelte.cjs +6 -5
  69. package/dist/components/svelte.cjs.map +1 -1
  70. package/dist/components/svelte.js +6 -5
  71. package/dist/components/svelte.js.map +1 -1
  72. package/dist/components/svg.cjs +1 -1
  73. package/dist/components/svg.js +2 -2
  74. package/dist/components/text.cjs +2 -2
  75. package/dist/components/text.js +3 -3
  76. package/dist/components/timeline.cjs +2 -2
  77. package/dist/components/timeline.js +4 -4
  78. package/dist/components/transitions.cjs +1 -1
  79. package/dist/components/transitions.js +2 -2
  80. package/dist/components/ui.cjs +3 -3
  81. package/dist/components/ui.js +5 -5
  82. package/dist/components/vue.cjs +6 -5
  83. package/dist/components/vue.cjs.map +1 -1
  84. package/dist/components/vue.js +6 -5
  85. package/dist/components/vue.js.map +1 -1
  86. package/dist/components/webgl.cjs +1 -1
  87. package/dist/components/webgl.js +2 -2
  88. package/dist/components.cjs +16 -5
  89. package/dist/components.cjs.map +1 -1
  90. package/dist/components.d.cts +73 -2
  91. package/dist/components.d.ts +73 -2
  92. package/dist/components.js +8 -7
  93. package/dist/components.js.map +1 -1
  94. package/dist/components.umd.js +2 -2
  95. package/dist/components.umd.js.map +1 -1
  96. package/dist/index.cjs +2 -2
  97. package/dist/index.js +2 -2
  98. package/dist/index.umd.js +2 -2
  99. package/dist/index.umd.js.map +1 -1
  100. package/docs/ROADMAP.md +1 -1
  101. package/docs/performance.md +24 -0
  102. package/package.json +21 -1
  103. package/dist/chunks/base-BtJDNCB6.js.map +0 -1
  104. package/dist/chunks/base-DE2yzxE7.cjs.map +0 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,15 @@ 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
+
10
19
  ## [4.4.0] - 2026-10-08
11
20
 
12
21
  ### Added
@@ -129,6 +129,7 @@ function getBase() {
129
129
  if (this._connected)
130
130
  return;
131
131
  this._connected = true;
132
+ styleLoader?.(this.localName);
132
133
  // Upgraded while the parser is still inside us (a <script> in <head>
133
134
  // defined the element): children/text are not there yet, so wait.
134
135
  if (typeof document !== 'undefined' && document.readyState === 'loading' && !this.nextSibling && !this.childNodes.length) {
@@ -209,10 +210,26 @@ function getBase() {
209
210
  return null;
210
211
  }
211
212
  keyframes = adaptKeyframes(keyframes);
213
+ if (active >= maxActive) {
214
+ applyFrame(el, keyframes[keyframes.length - 1]);
215
+ return null;
216
+ }
212
217
  const k = motionScale();
213
218
  if (k !== 1 && k > 0 && typeof options.duration === 'number')
214
219
  options = { ...options, duration: options.duration * k, delay: (options.delay || 0) * k };
215
- return el.animate(keyframes, options);
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;
216
233
  }
217
234
  emit(type, detail) {
218
235
  return this.dispatchEvent(new CustomEvent(`usa:${type}`, { detail, bubbles: true, cancelable: true }));
@@ -256,17 +273,87 @@ function srText(text) {
256
273
  s.textContent = text;
257
274
  return s;
258
275
  }
259
- /** requestAnimationFrame with a timeout fallback (jsdom / hidden documents). */
260
- const raf = (cb) => typeof requestAnimationFrame === 'function' ? requestAnimationFrame(cb) : setTimeout(() => cb(Date.now()), 16);
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
+ };
261
325
  /** Monotonic time in ms (rAF callback timestamps differ between environments, so loops use this). */
262
326
  const now = () => (typeof performance !== 'undefined' ? performance.now() : Date.now());
263
327
  const caf = (id) => {
264
- if (typeof cancelAnimationFrame === 'function')
265
- cancelAnimationFrame(id);
266
- else
267
- clearTimeout(id);
328
+ frameQueue.delete(id);
268
329
  };
269
- /** Spring-ish easing used across the components. */
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
+ }
270
357
  const EASE_OUT = 'cubic-bezier(0.22, 1, 0.36, 1)';
271
358
  const EASE_SPRING = 'cubic-bezier(0.34, 1.56, 0.64, 1)';
272
359
  /** Windows Fluent "decelerate" / "point-to-point" curves. */
@@ -281,5 +368,5 @@ function kindOf(el, valid, fallback) {
281
368
  }
282
369
  const clamp = (v, min, max) => Math.min(max, Math.max(min, v));
283
370
 
284
- export { EASE_SPRING as E, FLUENT_DECELERATE as F, MOTION_SCALE as M, MOTION_SENSITIVITY_LEVELS as a, adaptKeyframes as b, canDefine as c, configureComponents as d, getMotionSensitivity as e, clamp as f, getMotionIntensity as g, caf as h, applyFrame as i, adoptStyles as j, defineElement as k, EASE_OUT as l, motionScale as m, now as n, kindOf as o, prefersReducedMotion as p, srText as q, raf as r, shadowStyles as s };
285
- //# sourceMappingURL=base-BtJDNCB6.js.map
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 : f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getBase() {
131
131
  if (this._connected)
132
132
  return;
133
133
  this._connected = true;
134
+ styleLoader?.(this.localName);
134
135
  // Upgraded while the parser is still inside us (a <script> in <head>
135
136
  // defined the element): children/text are not there yet, so wait.
136
137
  if (typeof document !== 'undefined' && document.readyState === 'loading' && !this.nextSibling && !this.childNodes.length) {
@@ -211,10 +212,26 @@ function getBase() {
211
212
  return null;
212
213
  }
213
214
  keyframes = adaptKeyframes(keyframes);
215
+ if (active >= maxActive) {
216
+ applyFrame(el, keyframes[keyframes.length - 1]);
217
+ return null;
218
+ }
214
219
  const k = motionScale();
215
220
  if (k !== 1 && k > 0 && typeof options.duration === 'number')
216
221
  options = { ...options, duration: options.duration * k, delay: (options.delay || 0) * k };
217
- return el.animate(keyframes, options);
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;
218
235
  }
219
236
  emit(type, detail) {
220
237
  return this.dispatchEvent(new CustomEvent(`usa:${type}`, { detail, bubbles: true, cancelable: true }));
@@ -258,17 +275,87 @@ function srText(text) {
258
275
  s.textContent = text;
259
276
  return s;
260
277
  }
261
- /** requestAnimationFrame with a timeout fallback (jsdom / hidden documents). */
262
- const raf = (cb) => typeof requestAnimationFrame === 'function' ? requestAnimationFrame(cb) : setTimeout(() => cb(Date.now()), 16);
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
+ };
263
327
  /** Monotonic time in ms (rAF callback timestamps differ between environments, so loops use this). */
264
328
  const now = () => (typeof performance !== 'undefined' ? performance.now() : Date.now());
265
329
  const caf = (id) => {
266
- if (typeof cancelAnimationFrame === 'function')
267
- cancelAnimationFrame(id);
268
- else
269
- clearTimeout(id);
330
+ frameQueue.delete(id);
270
331
  };
271
- /** Spring-ish easing used across the components. */
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
+ }
272
359
  const EASE_OUT = 'cubic-bezier(0.22, 1, 0.36, 1)';
273
360
  const EASE_SPRING = 'cubic-bezier(0.34, 1.56, 0.64, 1)';
274
361
  /** Windows Fluent "decelerate" / "point-to-point" curves. */
@@ -288,8 +375,10 @@ exports.EASE_SPRING = EASE_SPRING;
288
375
  exports.FLUENT_DECELERATE = FLUENT_DECELERATE;
289
376
  exports.MOTION_SCALE = MOTION_SCALE;
290
377
  exports.MOTION_SENSITIVITY_LEVELS = MOTION_SENSITIVITY_LEVELS;
378
+ exports.activeAnimations = activeAnimations;
291
379
  exports.adaptKeyframes = adaptKeyframes;
292
380
  exports.adoptStyles = adoptStyles;
381
+ exports.animationBudget = animationBudget;
293
382
  exports.applyFrame = applyFrame;
294
383
  exports.caf = caf;
295
384
  exports.canDefine = canDefine;
@@ -301,8 +390,12 @@ exports.getMotionSensitivity = getMotionSensitivity;
301
390
  exports.kindOf = kindOf;
302
391
  exports.motionScale = motionScale;
303
392
  exports.now = now;
393
+ exports.onFrame = onFrame;
304
394
  exports.prefersReducedMotion = prefersReducedMotion;
305
395
  exports.raf = raf;
396
+ exports.schedulerStats = schedulerStats;
397
+ exports.setAnimationBudget = setAnimationBudget;
398
+ exports.setStyleLoader = setStyleLoader;
306
399
  exports.shadowStyles = shadowStyles;
307
400
  exports.srText = srText;
308
- //# sourceMappingURL=base-DE2yzxE7.cjs.map
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,e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;AAE7C;AACA,IAAI,WAAW,GAAmC,IAAI;AACtD;AACM,SAAU,cAAc,CAAC,EAAkC,EAAA;IAC/D,WAAW,GAAG,EAAE;AAClB;AAEO,MAAM,QAAQ,GAAG;AACjB,MAAM,WAAW,GAAG;AAC3B;AACO,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, f as clamp, h as caf, i as applyFrame, r as raf, m as motionScale, n as now } from './base-BtJDNCB6.js';
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-DS1nrx5L.js.map
260
+ //# sourceMappingURL=core-CJHJeMI_.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"core-DS1nrx5L.js","sources":["../../src/components/timeline/core.ts"],"sourcesContent":["import { prefersReducedMotion, motionScale, applyFrame, raf, caf, now, clamp } from '../base';\nimport { resolveDurationToken, resolveEasingToken } from '../tokens/index';\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 or a motion token name (`'fast'`, `'slow'`…; 4.2). Default: timeline default, 600. */\n duration?: number | string;\n /** CSS easing or a motion token name (`'emphasized'`, `'spring'`…; 4.2). 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 (JS engine only). */\n offset?: number;\n /** Smoothing 0–1 (0 = immediate, default 0). Smoothing needs the JS engine. */\n smooth?: number;\n /**\n * 4.1: which progress source drives the timeline.\n * - `'view'` (default): `source` moving through the viewport (CSS `ViewTimeline`, range `cover`).\n * - `'scroll'`: the scroll position of `source` itself (a scroll container; CSS `ScrollTimeline`).\n */\n source?: 'view' | 'scroll';\n /** 4.1: `'auto'` (default) uses the browser's native scroll-driven animations when available, `'js'` forces the fallback. */\n engine?: 'auto' | 'native' | 'js';\n /** 4.1: scroll axis, `'block'` (default) · `'inline'` · `'x'` · `'y'`. */\n axis?: 'block' | 'inline' | 'x' | 'y';\n}\n\n/** The function `scrub()` returns: call it to stop. `native` tells which engine runs it. */\nexport interface ScrubHandle {\n (): void;\n /** `true` when the browser's ScrollTimeline / ViewTimeline drives it (compositor, no JS per frame). */\n readonly native: boolean;\n}\n\n/** 4.1: whether `scrub()` can use native ScrollTimeline / ViewTimeline here. */\nexport function supportsNativeScrub(source: 'view' | 'scroll' = 'view'): boolean {\n const g = globalThis as any;\n return typeof g[source === 'scroll' ? 'ScrollTimeline' : 'ViewTimeline'] === 'function' && typeof g.Element?.prototype?.animate === 'function';\n}\n\nconst handle = (stop: () => void, native: boolean): ScrubHandle => Object.assign(stop, { native }) as ScrubHandle;\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 /**\n * Tie progress to scroll: `source` moving through the viewport (or, with\n * `{ source: 'scroll' }`, a scroll container's own position). Runs on native\n * ScrollTimeline / ViewTimeline when available (and no `smooth`, `offset`,\n * `call()` cues or `onUpdate` need JS), else on a rAF-throttled listener.\n * Returns a stop function with a `native` flag.\n */\n scrub(source: Element, options?: ScrubOptions): ScrubHandle;\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 = resolveDurationToken(o.duration ?? d.duration, 600);\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: resolveEasingToken(o.easing ?? d.easing, 'cubic-bezier(0.22, 1, 0.36, 1)') });\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 handle(() => {}, false);\n }\n const mode = o.source ?? 'view';\n const axis = o.axis ?? 'block';\n const needsJs = !!o.smooth || !!o.offset || cues.length > 0 || !!options.onUpdate || o.engine === 'js';\n if (!needsJs && total() > 0 && supportsNativeScrub(mode) && steps.every((st) => typeof (st.el as HTMLElement).animate === 'function')) {\n // Native: one scroll-driven animation per step, its slice of the\n // timeline mapped onto the scroll range (`cover` for a view timeline).\n const g = globalThis as any;\n const tl = mode === 'scroll' ? new g.ScrollTimeline({ source, axis }) : new g.ViewTimeline({ subject: source, axis });\n const T = total();\n steps.forEach((st) => st.anim?.cancel?.());\n built = false;\n const pct = (ms: number) => `${((ms / T) * 100).toFixed(3)}%`;\n const live = steps.map((st) => {\n const range = mode === 'view' ? { rangeStart: `cover ${pct(st.start)}`, rangeEnd: `cover ${pct(st.start + st.duration)}` } : {};\n const timing: any = { easing: st.easing, fill: 'both', timeline: tl, ...range };\n if (mode === 'scroll') Object.assign(timing, { duration: 'auto', rangeStart: pct(st.start), rangeEnd: pct(st.start + st.duration) });\n return (st.el as HTMLElement).animate(st.frames, timing);\n });\n return handle(() => {\n live.forEach((a) => a.cancel());\n render(t, t);\n }, true);\n }\n let id = 0;\n let cur = t;\n const scroller = mode === 'scroll' ? (source as HTMLElement) : null;\n const progressNow = () => {\n const x = axis === 'x' || axis === 'inline';\n if (scroller) {\n const max = x ? scroller.scrollWidth - scroller.clientWidth : scroller.scrollHeight - scroller.clientHeight;\n return clamp((x ? scroller.scrollLeft : scroller.scrollTop) / (max || 1), 0, 1);\n }\n const r = source.getBoundingClientRect();\n const vh = (x ? window.innerWidth : window.innerHeight) || 1;\n const start = x ? r.left : r.top;\n const size = x ? r.width : r.height;\n return clamp((vh + (o.offset ?? 0) - start) / (vh + size || 1), 0, 1);\n };\n const update = () => {\n id = 0;\n const goal = progressNow() * 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 const target: EventTarget = scroller || window;\n target.addEventListener('scroll', onScroll, { passive: true });\n window.addEventListener('resize', onScroll, { passive: true });\n update();\n return handle(() => {\n target.removeEventListener('scroll', onScroll);\n window.removeEventListener('resize', onScroll);\n if (id) caf(id);\n }, false);\n },\n cancel() {\n stop();\n settle?.();\n steps.forEach((s) => s.anim?.cancel?.());\n built = false;\n },\n };\n return api;\n}\n"],"names":[],"mappings":";;;AA2DA;AACM,SAAU,mBAAmB,CAAC,MAAA,GAA4B,MAAM,EAAA;IACpE,MAAM,CAAC,GAAG,UAAiB;AAC3B,IAAA,OAAO,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ,GAAG,gBAAgB,GAAG,cAAc,CAAC,KAAK,UAAU,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,KAAK,UAAU;AAChJ;AAEA,MAAM,MAAM,GAAG,CAAC,IAAgB,EAAE,MAAe,KAAkB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAgB;AAoCjH;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,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,C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AAI,IAAI,CAAC,GAAG,CAAC,IAAI,GAAG,GAAG,CAAC,GAAG,GAAG;AAAE,oBAAA,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC;AACxD,YAAA,CAAC;AACD,YAAA,MAAM,QAAQ,GAAG,MAAK,EAAG,IAAI,CAAC,EAAE;gBAAE,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACrD,YAAA,MAAM,MAAM,GAAgB,QAAQ,IAAI,MAAM;AAC9C,YAAA,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC9D,YAAA,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC9D,YAAA,MAAM,EAAE;YACR,OAAO,MAAM,CAAC,MAAK;AACjB,gBAAA,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC;AAC9C,gBAAA,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC;AAC9C,gBAAA,IAAI,EAAE;oBAAE,GAAG,CAAC,EAAE,CAAC;YACjB,CAAC,EAAE,KAAK,CAAC;QACX,CAAC;QACD,MAAM,GAAA;AACJ,YAAA,IAAI,EAAE;YACN,MAAM,IAAI;AACV,YAAA,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC;YACxC,KAAK,GAAG,KAAK;QACf,CAAC;KACF;AACD,IAAA,OAAO,GAAG;AACZ;;;;"}
1
+ {"version":3,"file":"core-CJHJeMI_.js","sources":["../../src/components/timeline/core.ts"],"sourcesContent":["import { prefersReducedMotion, motionScale, applyFrame, raf, caf, now, clamp } from '../base';\nimport { resolveDurationToken, resolveEasingToken } from '../tokens/index';\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 or a motion token name (`'fast'`, `'slow'`…; 4.2). Default: timeline default, 600. */\n duration?: number | string;\n /** CSS easing or a motion token name (`'emphasized'`, `'spring'`…; 4.2). 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 (JS engine only). */\n offset?: number;\n /** Smoothing 0–1 (0 = immediate, default 0). Smoothing needs the JS engine. */\n smooth?: number;\n /**\n * 4.1: which progress source drives the timeline.\n * - `'view'` (default): `source` moving through the viewport (CSS `ViewTimeline`, range `cover`).\n * - `'scroll'`: the scroll position of `source` itself (a scroll container; CSS `ScrollTimeline`).\n */\n source?: 'view' | 'scroll';\n /** 4.1: `'auto'` (default) uses the browser's native scroll-driven animations when available, `'js'` forces the fallback. */\n engine?: 'auto' | 'native' | 'js';\n /** 4.1: scroll axis, `'block'` (default) · `'inline'` · `'x'` · `'y'`. */\n axis?: 'block' | 'inline' | 'x' | 'y';\n}\n\n/** The function `scrub()` returns: call it to stop. `native` tells which engine runs it. */\nexport interface ScrubHandle {\n (): void;\n /** `true` when the browser's ScrollTimeline / ViewTimeline drives it (compositor, no JS per frame). */\n readonly native: boolean;\n}\n\n/** 4.1: whether `scrub()` can use native ScrollTimeline / ViewTimeline here. */\nexport function supportsNativeScrub(source: 'view' | 'scroll' = 'view'): boolean {\n const g = globalThis as any;\n return typeof g[source === 'scroll' ? 'ScrollTimeline' : 'ViewTimeline'] === 'function' && typeof g.Element?.prototype?.animate === 'function';\n}\n\nconst handle = (stop: () => void, native: boolean): ScrubHandle => Object.assign(stop, { native }) as ScrubHandle;\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 /**\n * Tie progress to scroll: `source` moving through the viewport (or, with\n * `{ source: 'scroll' }`, a scroll container's own position). Runs on native\n * ScrollTimeline / ViewTimeline when available (and no `smooth`, `offset`,\n * `call()` cues or `onUpdate` need JS), else on a rAF-throttled listener.\n * Returns a stop function with a `native` flag.\n */\n scrub(source: Element, options?: ScrubOptions): ScrubHandle;\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 = resolveDurationToken(o.duration ?? d.duration, 600);\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: resolveEasingToken(o.easing ?? d.easing, 'cubic-bezier(0.22, 1, 0.36, 1)') });\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 handle(() => {}, false);\n }\n const mode = o.source ?? 'view';\n const axis = o.axis ?? 'block';\n const needsJs = !!o.smooth || !!o.offset || cues.length > 0 || !!options.onUpdate || o.engine === 'js';\n if (!needsJs && total() > 0 && supportsNativeScrub(mode) && steps.every((st) => typeof (st.el as HTMLElement).animate === 'function')) {\n // Native: one scroll-driven animation per step, its slice of the\n // timeline mapped onto the scroll range (`cover` for a view timeline).\n const g = globalThis as any;\n const tl = mode === 'scroll' ? new g.ScrollTimeline({ source, axis }) : new g.ViewTimeline({ subject: source, axis });\n const T = total();\n steps.forEach((st) => st.anim?.cancel?.());\n built = false;\n const pct = (ms: number) => `${((ms / T) * 100).toFixed(3)}%`;\n const live = steps.map((st) => {\n const range = mode === 'view' ? { rangeStart: `cover ${pct(st.start)}`, rangeEnd: `cover ${pct(st.start + st.duration)}` } : {};\n const timing: any = { easing: st.easing, fill: 'both', timeline: tl, ...range };\n if (mode === 'scroll') Object.assign(timing, { duration: 'auto', rangeStart: pct(st.start), rangeEnd: pct(st.start + st.duration) });\n return (st.el as HTMLElement).animate(st.frames, timing);\n });\n return handle(() => {\n live.forEach((a) => a.cancel());\n render(t, t);\n }, true);\n }\n let id = 0;\n let cur = t;\n const scroller = mode === 'scroll' ? (source as HTMLElement) : null;\n const progressNow = () => {\n const x = axis === 'x' || axis === 'inline';\n if (scroller) {\n const max = x ? scroller.scrollWidth - scroller.clientWidth : scroller.scrollHeight - scroller.clientHeight;\n return clamp((x ? scroller.scrollLeft : scroller.scrollTop) / (max || 1), 0, 1);\n }\n const r = source.getBoundingClientRect();\n const vh = (x ? window.innerWidth : window.innerHeight) || 1;\n const start = x ? r.left : r.top;\n const size = x ? r.width : r.height;\n return clamp((vh + (o.offset ?? 0) - start) / (vh + size || 1), 0, 1);\n };\n const update = () => {\n id = 0;\n const goal = progressNow() * 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 const target: EventTarget = scroller || window;\n target.addEventListener('scroll', onScroll, { passive: true });\n window.addEventListener('resize', onScroll, { passive: true });\n update();\n return handle(() => {\n target.removeEventListener('scroll', onScroll);\n window.removeEventListener('resize', onScroll);\n if (id) caf(id);\n }, false);\n },\n cancel() {\n stop();\n settle?.();\n steps.forEach((s) => s.anim?.cancel?.());\n built = false;\n },\n };\n return api;\n}\n"],"names":[],"mappings":";;;AA2DA;AACM,SAAU,mBAAmB,CAAC,MAAA,GAA4B,MAAM,EAAA;IACpE,MAAM,CAAC,GAAG,UAAiB;AAC3B,IAAA,OAAO,OAAO,CAAC,CAAC,MAAM,KAAK,QAAQ,GAAG,gBAAgB,GAAG,cAAc,CAAC,KAAK,UAAU,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,KAAK,UAAU;AAChJ;AAEA,MAAM,MAAM,GAAG,CAAC,IAAgB,EAAE,MAAe,KAAkB,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAgB;AAoCjH;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,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;IAC/F,YAAY,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,mBAAmB,EAAE,EAAE,EAAE,OAAO,EAAE,CAAC,EAAE,SAAS,EAAE,MAAM,EAA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AAM,QAAQ,GAAG,MAAK,EAAG,IAAI,CAAC,EAAE;gBAAE,EAAE,GAAG,GAAG,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;AACrD,YAAA,MAAM,MAAM,GAAgB,QAAQ,IAAI,MAAM;AAC9C,YAAA,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC9D,YAAA,MAAM,CAAC,gBAAgB,CAAC,QAAQ,EAAE,QAAQ,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC;AAC9D,YAAA,MAAM,EAAE;YACR,OAAO,MAAM,CAAC,MAAK;AACjB,gBAAA,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC;AAC9C,gBAAA,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,QAAQ,CAAC;AAC9C,gBAAA,IAAI,EAAE;oBAAE,GAAG,CAAC,EAAE,CAAC;YACjB,CAAC,EAAE,KAAK,CAAC;QACX,CAAC;QACD,MAAM,GAAA;AACJ,YAAA,IAAI,EAAE;YACN,MAAM,IAAI;AACV,YAAA,KAAK,CAAC,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,IAAI,EAAE,MAAM,IAAI,CAAC;YACxC,KAAK,GAAG,KAAK;QACf,CAAC;KACF;AACD,IAAA,OAAO,GAAG;AACZ;;;;"}
@@ -1,4 +1,4 @@
1
- import { f as clamp } from './base-BtJDNCB6.js';
1
+ import { j as clamp } from './base-CZiIAMBc.js';
2
2
 
3
3
  /** The swipe a pointer release represents, or `null` (pure). */
4
4
  function swipeDirection(dx, dy, vx, vy, o = {}) {
@@ -178,4 +178,4 @@ function gesture(el, h, o = {}) {
178
178
  }
179
179
 
180
180
  export { gesture as g, pinchScale as p, swipeDirection as s };
181
- //# sourceMappingURL=core-DX6pdOoY.js.map
181
+ //# sourceMappingURL=core-COi3DrLx.js.map