use-scroll-animate 4.0.1 → 4.1.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 +13 -0
- package/dist/chunks/{base-ZARFccur.js → base-BPG5zvex.js} +2 -2
- package/dist/chunks/{base-ZARFccur.js.map → base-BPG5zvex.js.map} +1 -1
- package/dist/chunks/{core-DXqZm5Il.cjs → core-CLu8ZrC-.cjs} +52 -10
- package/dist/chunks/core-CLu8ZrC-.cjs.map +1 -0
- package/dist/chunks/{core-Co-6AL0h.js → core-QTFk4kgO.js} +53 -12
- package/dist/chunks/core-QTFk4kgO.js.map +1 -0
- package/dist/chunks/{core-DKY-fVzR.js → core-eXX8rB_b.js} +2 -2
- package/dist/chunks/{core-DKY-fVzR.js.map → core-eXX8rB_b.js.map} +1 -1
- package/dist/chunks/{spring-E2ickYNI.js → spring-BziPsW3r.js} +2 -2
- package/dist/chunks/{spring-E2ickYNI.js.map → spring-BziPsW3r.js.map} +1 -1
- package/dist/chunks/{variants-DvnxvRCM.js → variants-BVYMcxRv.js} +2 -2
- package/dist/chunks/{variants-DvnxvRCM.js.map → variants-BVYMcxRv.js.map} +1 -1
- package/dist/components/angular.cjs +1 -1
- package/dist/components/angular.d.cts +29 -5
- package/dist/components/angular.d.ts +29 -5
- package/dist/components/angular.js +5 -5
- package/dist/components/background.js +3 -3
- package/dist/components/cards.js +3 -3
- package/dist/components/click.js +3 -3
- package/dist/components/depth.js +4 -4
- package/dist/components/feedback.js +2 -2
- package/dist/components/gesture.js +5 -5
- package/dist/components/interaction.js +2 -2
- package/dist/components/layout.js +2 -2
- package/dist/components/packs.js +2 -2
- package/dist/components/page.js +3 -3
- package/dist/components/physics.js +4 -4
- package/dist/components/reveal.js +2 -2
- package/dist/components/solid.cjs +1 -1
- package/dist/components/solid.d.cts +29 -5
- package/dist/components/solid.d.ts +29 -5
- package/dist/components/solid.js +5 -5
- package/dist/components/svelte.cjs +1 -1
- package/dist/components/svelte.d.cts +29 -5
- package/dist/components/svelte.d.ts +29 -5
- package/dist/components/svelte.js +5 -5
- package/dist/components/svg.js +2 -2
- package/dist/components/text.js +2 -2
- package/dist/components/timeline.cjs +9 -2
- package/dist/components/timeline.cjs.map +1 -1
- package/dist/components/timeline.d.cts +33 -7
- package/dist/components/timeline.d.ts +33 -7
- package/dist/components/timeline.js +11 -5
- package/dist/components/timeline.js.map +1 -1
- package/dist/components/transitions.js +2 -2
- package/dist/components/ui.js +5 -5
- package/dist/components/vue.cjs +1 -1
- package/dist/components/vue.d.cts +29 -5
- package/dist/components/vue.d.ts +29 -5
- package/dist/components/vue.js +5 -5
- package/dist/components/webgl.js +2 -2
- package/dist/components.cjs +2 -1
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +34 -8
- package/dist/components.d.ts +34 -8
- package/dist/components.js +7 -7
- package/dist/components.umd.js +2 -2
- package/dist/components.umd.js.map +1 -1
- package/dist/index.cjs +2 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -6
- package/dist/index.d.ts +30 -6
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.umd.js +2 -2
- package/dist/index.umd.js.map +1 -1
- package/docs/API.md +3 -1
- package/docs/ROADMAP.md +1 -1
- package/package.json +1 -1
- package/dist/chunks/core-Co-6AL0h.js.map +0 -1
- package/dist/chunks/core-DXqZm5Il.cjs.map +0 -1
|
@@ -17,7 +17,7 @@ require('./click.cjs');
|
|
|
17
17
|
require('./ui.cjs');
|
|
18
18
|
require('./page.cjs');
|
|
19
19
|
require('./timeline.cjs');
|
|
20
|
-
require('../chunks/core-
|
|
20
|
+
require('../chunks/core-CLu8ZrC-.cjs');
|
|
21
21
|
require('./gesture.cjs');
|
|
22
22
|
require('../chunks/core-IaorbTdu.cjs');
|
|
23
23
|
require('./svg.cjs');
|
|
@@ -1295,10 +1295,26 @@ interface TimelineStepOptions {
|
|
|
1295
1295
|
stagger?: number;
|
|
1296
1296
|
}
|
|
1297
1297
|
interface ScrubOptions {
|
|
1298
|
-
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts. */
|
|
1298
|
+
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts (JS engine only). */
|
|
1299
1299
|
offset?: number;
|
|
1300
|
-
/** Smoothing 0–1 (0 = immediate, default 0). */
|
|
1300
|
+
/** Smoothing 0–1 (0 = immediate, default 0). Smoothing needs the JS engine. */
|
|
1301
1301
|
smooth?: number;
|
|
1302
|
+
/**
|
|
1303
|
+
* 4.1: which progress source drives the timeline.
|
|
1304
|
+
* - `'view'` (default): `source` moving through the viewport (CSS `ViewTimeline`, range `cover`).
|
|
1305
|
+
* - `'scroll'`: the scroll position of `source` itself (a scroll container; CSS `ScrollTimeline`).
|
|
1306
|
+
*/
|
|
1307
|
+
source?: 'view' | 'scroll';
|
|
1308
|
+
/** 4.1: `'auto'` (default) uses the browser's native scroll-driven animations when available, `'js'` forces the fallback. */
|
|
1309
|
+
engine?: 'auto' | 'native' | 'js';
|
|
1310
|
+
/** 4.1: scroll axis, `'block'` (default) · `'inline'` · `'x'` · `'y'`. */
|
|
1311
|
+
axis?: 'block' | 'inline' | 'x' | 'y';
|
|
1312
|
+
}
|
|
1313
|
+
/** The function `scrub()` returns: call it to stop. `native` tells which engine runs it. */
|
|
1314
|
+
interface ScrubHandle {
|
|
1315
|
+
(): void;
|
|
1316
|
+
/** `true` when the browser's ScrollTimeline / ViewTimeline drives it (compositor, no JS per frame). */
|
|
1317
|
+
readonly native: boolean;
|
|
1302
1318
|
}
|
|
1303
1319
|
interface Timeline {
|
|
1304
1320
|
/** Total length in ms. */
|
|
@@ -1322,8 +1338,14 @@ interface Timeline {
|
|
|
1322
1338
|
seek(to: TimelinePosition): Timeline;
|
|
1323
1339
|
/** Get or set progress 0–1. */
|
|
1324
1340
|
progress(p?: number): number;
|
|
1325
|
-
/**
|
|
1326
|
-
|
|
1341
|
+
/**
|
|
1342
|
+
* Tie progress to scroll: `source` moving through the viewport (or, with
|
|
1343
|
+
* `{ source: 'scroll' }`, a scroll container's own position). Runs on native
|
|
1344
|
+
* ScrollTimeline / ViewTimeline when available (and no `smooth`, `offset`,
|
|
1345
|
+
* `call()` cues or `onUpdate` need JS), else on a rAF-throttled listener.
|
|
1346
|
+
* Returns a stop function with a `native` flag.
|
|
1347
|
+
*/
|
|
1348
|
+
scrub(source: Element, options?: ScrubOptions): ScrubHandle;
|
|
1327
1349
|
/** Stop and drop every animation (elements keep their last frame). */
|
|
1328
1350
|
cancel(): void;
|
|
1329
1351
|
}
|
|
@@ -1337,7 +1359,9 @@ interface Timeline {
|
|
|
1337
1359
|
* Attributes: `trigger` (`view` default · `click` · `manual`), `scrub`
|
|
1338
1360
|
* (progress follows scroll instead of playing), `overlap` (ms each step
|
|
1339
1361
|
* overlaps the previous, default 0), `duration` (600), `stagger` (ms),
|
|
1340
|
-
* `repeat` (replay every time it enters the viewport).
|
|
1362
|
+
* `repeat` (replay every time it enters the viewport). 4.1: `scrub` runs on native
|
|
1363
|
+
* ScrollTimeline / ViewTimeline when supported (`data-native` is set); `scrub="js"`,
|
|
1364
|
+
* `scrub="scroll"` and `smooth` tune it. Methods: `play()`,
|
|
1341
1365
|
* `reverse()`, `seek(t)`; property `timeline`. Event `usa:complete`.
|
|
1342
1366
|
* Reduced motion: steps appear in their final state.
|
|
1343
1367
|
*/
|
|
@@ -1295,10 +1295,26 @@ interface TimelineStepOptions {
|
|
|
1295
1295
|
stagger?: number;
|
|
1296
1296
|
}
|
|
1297
1297
|
interface ScrubOptions {
|
|
1298
|
-
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts. */
|
|
1298
|
+
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts (JS engine only). */
|
|
1299
1299
|
offset?: number;
|
|
1300
|
-
/** Smoothing 0–1 (0 = immediate, default 0). */
|
|
1300
|
+
/** Smoothing 0–1 (0 = immediate, default 0). Smoothing needs the JS engine. */
|
|
1301
1301
|
smooth?: number;
|
|
1302
|
+
/**
|
|
1303
|
+
* 4.1: which progress source drives the timeline.
|
|
1304
|
+
* - `'view'` (default): `source` moving through the viewport (CSS `ViewTimeline`, range `cover`).
|
|
1305
|
+
* - `'scroll'`: the scroll position of `source` itself (a scroll container; CSS `ScrollTimeline`).
|
|
1306
|
+
*/
|
|
1307
|
+
source?: 'view' | 'scroll';
|
|
1308
|
+
/** 4.1: `'auto'` (default) uses the browser's native scroll-driven animations when available, `'js'` forces the fallback. */
|
|
1309
|
+
engine?: 'auto' | 'native' | 'js';
|
|
1310
|
+
/** 4.1: scroll axis, `'block'` (default) · `'inline'` · `'x'` · `'y'`. */
|
|
1311
|
+
axis?: 'block' | 'inline' | 'x' | 'y';
|
|
1312
|
+
}
|
|
1313
|
+
/** The function `scrub()` returns: call it to stop. `native` tells which engine runs it. */
|
|
1314
|
+
interface ScrubHandle {
|
|
1315
|
+
(): void;
|
|
1316
|
+
/** `true` when the browser's ScrollTimeline / ViewTimeline drives it (compositor, no JS per frame). */
|
|
1317
|
+
readonly native: boolean;
|
|
1302
1318
|
}
|
|
1303
1319
|
interface Timeline {
|
|
1304
1320
|
/** Total length in ms. */
|
|
@@ -1322,8 +1338,14 @@ interface Timeline {
|
|
|
1322
1338
|
seek(to: TimelinePosition): Timeline;
|
|
1323
1339
|
/** Get or set progress 0–1. */
|
|
1324
1340
|
progress(p?: number): number;
|
|
1325
|
-
/**
|
|
1326
|
-
|
|
1341
|
+
/**
|
|
1342
|
+
* Tie progress to scroll: `source` moving through the viewport (or, with
|
|
1343
|
+
* `{ source: 'scroll' }`, a scroll container's own position). Runs on native
|
|
1344
|
+
* ScrollTimeline / ViewTimeline when available (and no `smooth`, `offset`,
|
|
1345
|
+
* `call()` cues or `onUpdate` need JS), else on a rAF-throttled listener.
|
|
1346
|
+
* Returns a stop function with a `native` flag.
|
|
1347
|
+
*/
|
|
1348
|
+
scrub(source: Element, options?: ScrubOptions): ScrubHandle;
|
|
1327
1349
|
/** Stop and drop every animation (elements keep their last frame). */
|
|
1328
1350
|
cancel(): void;
|
|
1329
1351
|
}
|
|
@@ -1337,7 +1359,9 @@ interface Timeline {
|
|
|
1337
1359
|
* Attributes: `trigger` (`view` default · `click` · `manual`), `scrub`
|
|
1338
1360
|
* (progress follows scroll instead of playing), `overlap` (ms each step
|
|
1339
1361
|
* overlaps the previous, default 0), `duration` (600), `stagger` (ms),
|
|
1340
|
-
* `repeat` (replay every time it enters the viewport).
|
|
1362
|
+
* `repeat` (replay every time it enters the viewport). 4.1: `scrub` runs on native
|
|
1363
|
+
* ScrollTimeline / ViewTimeline when supported (`data-native` is set); `scrub="js"`,
|
|
1364
|
+
* `scrub="scroll"` and `smooth` tune it. Methods: `play()`,
|
|
1341
1365
|
* `reverse()`, `seek(t)`; property `timeline`. Event `usa:complete`.
|
|
1342
1366
|
* Reduced motion: steps appear in their final state.
|
|
1343
1367
|
*/
|
|
@@ -2,23 +2,23 @@ import { defineComponents } from '../components.js';
|
|
|
2
2
|
import { b as bindUsa } from '../chunks/bind-B_CTL6Qn.js';
|
|
3
3
|
export { u as usaEventName } from '../chunks/bind-B_CTL6Qn.js';
|
|
4
4
|
import './reveal.js';
|
|
5
|
-
import '../chunks/base-
|
|
5
|
+
import '../chunks/base-BPG5zvex.js';
|
|
6
6
|
import './text.js';
|
|
7
7
|
import './interaction.js';
|
|
8
8
|
import './feedback.js';
|
|
9
9
|
import './background.js';
|
|
10
|
-
import '../chunks/variants-
|
|
10
|
+
import '../chunks/variants-BVYMcxRv.js';
|
|
11
11
|
import './transitions.js';
|
|
12
12
|
import './physics.js';
|
|
13
|
-
import '../chunks/spring-
|
|
13
|
+
import '../chunks/spring-BziPsW3r.js';
|
|
14
14
|
import './cards.js';
|
|
15
15
|
import './click.js';
|
|
16
16
|
import './ui.js';
|
|
17
17
|
import './page.js';
|
|
18
18
|
import './timeline.js';
|
|
19
|
-
import '../chunks/core-
|
|
19
|
+
import '../chunks/core-QTFk4kgO.js';
|
|
20
20
|
import './gesture.js';
|
|
21
|
-
import '../chunks/core-
|
|
21
|
+
import '../chunks/core-eXX8rB_b.js';
|
|
22
22
|
import './svg.js';
|
|
23
23
|
import './webgl.js';
|
|
24
24
|
import './depth.js';
|
package/dist/components/svg.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
export { a as configureComponents } from '../chunks/base-
|
|
1
|
+
import { b as clamp, m as motionScale, d as caf, p as prefersReducedMotion, n as now, r as raf, h as defineElement, i as EASE_OUT } from '../chunks/base-BPG5zvex.js';
|
|
2
|
+
export { a as configureComponents } from '../chunks/base-BPG5zvex.js';
|
|
3
3
|
|
|
4
4
|
const NUM = /-?(?:\d+\.?\d*|\.\d+)(?:e[-+]?\d+)?/gi;
|
|
5
5
|
/** `true` when two path strings share the same commands (so their numbers can be interpolated). */
|
package/dist/components/text.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as defineElement, j as srText,
|
|
2
|
-
export { a as configureComponents, p as prefersReducedMotion } from '../chunks/base-
|
|
1
|
+
import { h as defineElement, j as srText, d as caf, n as now, r as raf, i as EASE_OUT, E as EASE_SPRING, b as clamp } from '../chunks/base-BPG5zvex.js';
|
|
2
|
+
export { a as configureComponents, p as prefersReducedMotion } from '../chunks/base-BPG5zvex.js';
|
|
3
3
|
|
|
4
4
|
var css$5 = "usa-typewriter{white-space:pre-wrap}usa-typewriter .usa-tw-caret{display:inline-block;width:var(--usa-caret-width,0.08em);height:1.05em;margin-left:0.06em;vertical-align:-0.12em;background:var(--usa-caret-color,currentColor);animation:usa-caret 1.06s steps(1) infinite}usa-typewriter[data-typing] .usa-tw-caret{animation:none}usa-typewriter[data-no-cursor] .usa-tw-caret{display:none}@keyframes usa-caret{50%{opacity:0}}@media (prefers-reduced-motion:reduce){usa-typewriter .usa-tw-caret,usa-shimmer-text{animation:none}}";
|
|
5
5
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var base = require('../chunks/base-CXx7jZ-o.cjs');
|
|
4
|
-
var core = require('../chunks/core-
|
|
4
|
+
var core = require('../chunks/core-CLu8ZrC-.cjs');
|
|
5
5
|
|
|
6
6
|
var css = "usa-timeline{display:block}usa-timeline[scrub]{position:relative}@media (prefers-reduced-motion:reduce){usa-timeline [data-tl]{opacity:1 !important;transform:none !important;filter:none !important;clip-path:none !important}}";
|
|
7
7
|
|
|
@@ -44,7 +44,13 @@ function defineTimeline(tag = 'usa-timeline') {
|
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
if (this.flag('scrub')) {
|
|
47
|
-
|
|
47
|
+
// 4.1: native ScrollTimeline / ViewTimeline when available; `smooth`
|
|
48
|
+
// (0–0.95) or `scrub="js"` opt into the JS engine, `scrub="scroll"`
|
|
49
|
+
// follows this element's own scroll position.
|
|
50
|
+
const v = this.str('scrub');
|
|
51
|
+
const stop = tl.scrub(this, { smooth: this.num('smooth', 0), engine: v === 'js' ? 'js' : 'auto', source: v === 'scroll' ? 'scroll' : 'view' });
|
|
52
|
+
this.toggleAttribute('data-native', stop.native);
|
|
53
|
+
this.onCleanup(stop);
|
|
48
54
|
return;
|
|
49
55
|
}
|
|
50
56
|
const trigger = this.str('trigger', 'view');
|
|
@@ -97,6 +103,7 @@ exports.configureComponents = base.configureComponents;
|
|
|
97
103
|
exports.prefersReducedMotion = base.prefersReducedMotion;
|
|
98
104
|
exports.TIMELINE_PRESETS = core.TIMELINE_PRESETS;
|
|
99
105
|
exports.resolvePosition = core.resolvePosition;
|
|
106
|
+
exports.supportsNativeScrub = core.supportsNativeScrub;
|
|
100
107
|
exports.timeline = core.timeline;
|
|
101
108
|
exports.defineTimeline = defineTimeline;
|
|
102
109
|
exports.defineTimelineComponents = defineTimelineComponents;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeline.cjs","sources":["../../src/components/timeline/timeline-el.ts","../../src/components/timeline/index.ts"],"sourcesContent":["import { defineElement, type UsaElement } from '../base';\nimport { timeline, TIMELINE_PRESETS, type Timeline } from './core';\nimport css from './timeline.css?raw';\n\n/**\n * `<usa-timeline>` — declarative choreography. Every descendant with\n * `data-tl=\"<preset>\"` becomes a step, in document order; `data-at`\n * (`'-=200'`, `'<'`, `'label+=100'`, ms), `data-duration` and `data-label`\n * fine-tune it.\n *\n * Attributes: `trigger` (`view` default · `click` · `manual`), `scrub`\n * (progress follows scroll instead of playing), `overlap` (ms each step\n * overlaps the previous, default 0), `duration` (600), `stagger` (ms),\n * `repeat` (replay every time it enters the viewport). Methods: `play()`,\n * `reverse()`, `seek(t)`; property `timeline`. Event `usa:complete`.\n * Reduced motion: steps appear in their final state.\n */\nexport interface UsaTimelineElement extends UsaElement {\n readonly timeline: Timeline | null;\n play(): Promise<void>;\n reverse(): Promise<void>;\n seek(to: number | string): void;\n}\n\nexport function defineTimeline(tag = 'usa-timeline'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) =>\n class UsaTimeline extends Base {\n static get observedAttributes(): string[] {\n return ['scrub', 'trigger', 'overlap'];\n }\n private _tl: Timeline | null = null;\n\n get timeline(): Timeline | null {\n return this._tl;\n }\n\n play(): Promise<void> {\n return this._tl ? this._tl.play(0).then(() => void this.emit('complete')) : Promise.resolve();\n }\n\n reverse(): Promise<void> {\n return this._tl ? this._tl.reverse() : Promise.resolve();\n }\n\n seek(to: number | string): void {\n this._tl?.seek(to);\n }\n\n mount(): void {\n const overlap = this.num('overlap', 0);\n const tl = (this._tl = timeline({ defaults: { duration: this.num('duration', 600), stagger: this.num('stagger', 0) } }));\n this.querySelectorAll<HTMLElement>('[data-tl]').forEach((el, i) => {\n if (el.dataset.label) tl.label(el.dataset.label);\n const name = el.dataset.tl || 'fade';\n tl.to(el, TIMELINE_PRESETS[name] ? name : 'fade', {\n at: el.dataset.at ?? (i && overlap ? `-=${overlap}` : undefined),\n duration: el.dataset.duration ? Number(el.dataset.duration) : undefined,\n });\n });\n this.onCleanup(() => tl.cancel());\n if (this.reduced) {\n tl.seek(tl.duration);\n return;\n }\n if (this.flag('scrub')) {\n this.
|
|
1
|
+
{"version":3,"file":"timeline.cjs","sources":["../../src/components/timeline/timeline-el.ts","../../src/components/timeline/index.ts"],"sourcesContent":["import { defineElement, type UsaElement } from '../base';\nimport { timeline, TIMELINE_PRESETS, type Timeline } from './core';\nimport css from './timeline.css?raw';\n\n/**\n * `<usa-timeline>` — declarative choreography. Every descendant with\n * `data-tl=\"<preset>\"` becomes a step, in document order; `data-at`\n * (`'-=200'`, `'<'`, `'label+=100'`, ms), `data-duration` and `data-label`\n * fine-tune it.\n *\n * Attributes: `trigger` (`view` default · `click` · `manual`), `scrub`\n * (progress follows scroll instead of playing), `overlap` (ms each step\n * overlaps the previous, default 0), `duration` (600), `stagger` (ms),\n * `repeat` (replay every time it enters the viewport). 4.1: `scrub` runs on native\n * ScrollTimeline / ViewTimeline when supported (`data-native` is set); `scrub=\"js\"`,\n * `scrub=\"scroll\"` and `smooth` tune it. Methods: `play()`,\n * `reverse()`, `seek(t)`; property `timeline`. Event `usa:complete`.\n * Reduced motion: steps appear in their final state.\n */\nexport interface UsaTimelineElement extends UsaElement {\n readonly timeline: Timeline | null;\n play(): Promise<void>;\n reverse(): Promise<void>;\n seek(to: number | string): void;\n}\n\nexport function defineTimeline(tag = 'usa-timeline'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) =>\n class UsaTimeline extends Base {\n static get observedAttributes(): string[] {\n return ['scrub', 'trigger', 'overlap'];\n }\n private _tl: Timeline | null = null;\n\n get timeline(): Timeline | null {\n return this._tl;\n }\n\n play(): Promise<void> {\n return this._tl ? this._tl.play(0).then(() => void this.emit('complete')) : Promise.resolve();\n }\n\n reverse(): Promise<void> {\n return this._tl ? this._tl.reverse() : Promise.resolve();\n }\n\n seek(to: number | string): void {\n this._tl?.seek(to);\n }\n\n mount(): void {\n const overlap = this.num('overlap', 0);\n const tl = (this._tl = timeline({ defaults: { duration: this.num('duration', 600), stagger: this.num('stagger', 0) } }));\n this.querySelectorAll<HTMLElement>('[data-tl]').forEach((el, i) => {\n if (el.dataset.label) tl.label(el.dataset.label);\n const name = el.dataset.tl || 'fade';\n tl.to(el, TIMELINE_PRESETS[name] ? name : 'fade', {\n at: el.dataset.at ?? (i && overlap ? `-=${overlap}` : undefined),\n duration: el.dataset.duration ? Number(el.dataset.duration) : undefined,\n });\n });\n this.onCleanup(() => tl.cancel());\n if (this.reduced) {\n tl.seek(tl.duration);\n return;\n }\n if (this.flag('scrub')) {\n // 4.1: native ScrollTimeline / ViewTimeline when available; `smooth`\n // (0–0.95) or `scrub=\"js\"` opt into the JS engine, `scrub=\"scroll\"`\n // follows this element's own scroll position.\n const v = this.str('scrub');\n const stop = tl.scrub(this, { smooth: this.num('smooth', 0), engine: v === 'js' ? 'js' : 'auto', source: v === 'scroll' ? 'scroll' : 'view' });\n this.toggleAttribute('data-native', stop.native);\n this.onCleanup(stop);\n return;\n }\n const trigger = this.str('trigger', 'view');\n if (trigger === 'click') {\n // 4.0.1: show the finished composition until the first click\n // (it used to sit invisible at t=0); Enter / Space replay it too.\n tl.seek(tl.duration);\n this.listen(this, 'click', () => void this.play());\n this.listen(this, 'keydown', (e: KeyboardEvent) => {\n if (e.target === this && (e.key === 'Enter' || e.key === ' ')) {\n e.preventDefault();\n void this.play();\n }\n });\n if (!this.hasAttribute('tabindex')) this.tabIndex = 0;\n return;\n }\n tl.seek(0);\n if (trigger === 'view') {\n let played = false;\n this.inView((v) => {\n if (v && (!played || this.flag('repeat'))) {\n played = true;\n void this.play();\n } else if (!v && this.flag('repeat')) tl.seek(0);\n }, { threshold: 0.2 });\n }\n }\n\n unmount(): void {\n this._tl = null;\n }\n },\n { id: 'timeline', text: css }\n );\n}\n","/**\n * use-scroll-animate/components/timeline — choreography (v3.1).\n * `timeline()` chains, overlaps, labels, seeks, reverses and scroll-scrubs\n * WAAPI animations on one playhead; `<usa-timeline>` builds one from\n * `data-tl` children.\n */\nimport { defineTimeline, type UsaTimelineElement } from './timeline-el';\n\nexport { defineTimeline };\nexport { timeline, resolvePosition, TIMELINE_PRESETS, supportsNativeScrub } from './core';\nexport type { Timeline, TimelineOptions, TimelineStepOptions, TimelinePosition, ScrubOptions, ScrubHandle } from './core';\nexport type { UsaTimelineElement };\nexport { configureComponents, prefersReducedMotion } from '../base';\nexport type { ComponentsConfig, UsaElement } from '../base';\n\n/** Register every component of this category under its default tag. */\nexport function defineTimelineComponents(): void {\n defineTimeline();\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'usa-timeline': UsaTimelineElement;\n }\n}\n"],"names":["defineElement","timeline","TIMELINE_PRESETS"],"mappings":";;;;;;;AA0BM,SAAU,cAAc,CAAC,GAAG,GAAG,cAAc,EAAA;AACjD,IAAA,OAAOA,kBAAa,CAClB,GAAG,EACH,CAAC,IAAI,KACH,MAAM,WAAY,SAAQ,IAAI,CAAA;AAA9B,QAAA,WAAA,GAAA;;YAIU,IAAA,CAAA,GAAG,GAAoB,IAAI;QA0ErC;AA7EE,QAAA,WAAW,kBAAkB,GAAA;AAC3B,YAAA,OAAO,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC;QACxC;AAGA,QAAA,IAAI,QAAQ,GAAA;YACV,OAAO,IAAI,CAAC,GAAG;QACjB;QAEA,IAAI,GAAA;AACF,YAAA,OAAO,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,EAAE;QAC/F;QAEA,OAAO,GAAA;AACL,YAAA,OAAO,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE;QAC1D;AAEA,QAAA,IAAI,CAAC,EAAmB,EAAA;AACtB,YAAA,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC;QACpB;QAE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AC;AACV,YAAA,IAAI,OAAO,KAAK,MAAM,EAAE;gBACtB,IAAI,MAAM,GAAG,KAAK;AAClB,gBAAA,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,KAAI;AAChB,oBAAA,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE;wBACzC,MAAM,GAAG,IAAI;AACb,wBAAA,KAAK,IAAI,CAAC,IAAI,EAAE;oBAClB;yBAAO,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;AAAE,wBAAA,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AAClD,gBAAA,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;YACxB;QACF;QAEA,OAAO,GAAA;AACL,YAAA,IAAI,CAAC,GAAG,GAAG,IAAI;QACjB;KACD,EACH,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,CAC9B;AACH;;AC/GA;;;;;AAKG;AAUH;SACgB,wBAAwB,GAAA;AACtC,IAAA,cAAc,EAAE;AAClB;;;;;;;;;;;"}
|
|
@@ -73,11 +73,29 @@ interface TimelineOptions {
|
|
|
73
73
|
onUpdate?: (progress: number) => void;
|
|
74
74
|
}
|
|
75
75
|
interface ScrubOptions {
|
|
76
|
-
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts. */
|
|
76
|
+
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts (JS engine only). */
|
|
77
77
|
offset?: number;
|
|
78
|
-
/** Smoothing 0–1 (0 = immediate, default 0). */
|
|
78
|
+
/** Smoothing 0–1 (0 = immediate, default 0). Smoothing needs the JS engine. */
|
|
79
79
|
smooth?: number;
|
|
80
|
+
/**
|
|
81
|
+
* 4.1: which progress source drives the timeline.
|
|
82
|
+
* - `'view'` (default): `source` moving through the viewport (CSS `ViewTimeline`, range `cover`).
|
|
83
|
+
* - `'scroll'`: the scroll position of `source` itself (a scroll container; CSS `ScrollTimeline`).
|
|
84
|
+
*/
|
|
85
|
+
source?: 'view' | 'scroll';
|
|
86
|
+
/** 4.1: `'auto'` (default) uses the browser's native scroll-driven animations when available, `'js'` forces the fallback. */
|
|
87
|
+
engine?: 'auto' | 'native' | 'js';
|
|
88
|
+
/** 4.1: scroll axis, `'block'` (default) · `'inline'` · `'x'` · `'y'`. */
|
|
89
|
+
axis?: 'block' | 'inline' | 'x' | 'y';
|
|
90
|
+
}
|
|
91
|
+
/** The function `scrub()` returns: call it to stop. `native` tells which engine runs it. */
|
|
92
|
+
interface ScrubHandle {
|
|
93
|
+
(): void;
|
|
94
|
+
/** `true` when the browser's ScrollTimeline / ViewTimeline drives it (compositor, no JS per frame). */
|
|
95
|
+
readonly native: boolean;
|
|
80
96
|
}
|
|
97
|
+
/** 4.1: whether `scrub()` can use native ScrollTimeline / ViewTimeline here. */
|
|
98
|
+
declare function supportsNativeScrub(source?: 'view' | 'scroll'): boolean;
|
|
81
99
|
interface Timeline {
|
|
82
100
|
/** Total length in ms. */
|
|
83
101
|
readonly duration: number;
|
|
@@ -100,8 +118,14 @@ interface Timeline {
|
|
|
100
118
|
seek(to: TimelinePosition): Timeline;
|
|
101
119
|
/** Get or set progress 0–1. */
|
|
102
120
|
progress(p?: number): number;
|
|
103
|
-
/**
|
|
104
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Tie progress to scroll: `source` moving through the viewport (or, with
|
|
123
|
+
* `{ source: 'scroll' }`, a scroll container's own position). Runs on native
|
|
124
|
+
* ScrollTimeline / ViewTimeline when available (and no `smooth`, `offset`,
|
|
125
|
+
* `call()` cues or `onUpdate` need JS), else on a rAF-throttled listener.
|
|
126
|
+
* Returns a stop function with a `native` flag.
|
|
127
|
+
*/
|
|
128
|
+
scrub(source: Element, options?: ScrubOptions): ScrubHandle;
|
|
105
129
|
/** Stop and drop every animation (elements keep their last frame). */
|
|
106
130
|
cancel(): void;
|
|
107
131
|
}
|
|
@@ -133,7 +157,9 @@ declare function timeline(options?: TimelineOptions): Timeline;
|
|
|
133
157
|
* Attributes: `trigger` (`view` default · `click` · `manual`), `scrub`
|
|
134
158
|
* (progress follows scroll instead of playing), `overlap` (ms each step
|
|
135
159
|
* overlaps the previous, default 0), `duration` (600), `stagger` (ms),
|
|
136
|
-
* `repeat` (replay every time it enters the viewport).
|
|
160
|
+
* `repeat` (replay every time it enters the viewport). 4.1: `scrub` runs on native
|
|
161
|
+
* ScrollTimeline / ViewTimeline when supported (`data-native` is set); `scrub="js"`,
|
|
162
|
+
* `scrub="scroll"` and `smooth` tune it. Methods: `play()`,
|
|
137
163
|
* `reverse()`, `seek(t)`; property `timeline`. Event `usa:complete`.
|
|
138
164
|
* Reduced motion: steps appear in their final state.
|
|
139
165
|
*/
|
|
@@ -160,5 +186,5 @@ declare global {
|
|
|
160
186
|
}
|
|
161
187
|
}
|
|
162
188
|
|
|
163
|
-
export { TIMELINE_PRESETS, configureComponents, defineTimeline, defineTimelineComponents, prefersReducedMotion, resolvePosition, timeline };
|
|
164
|
-
export type { ComponentsConfig, ScrubOptions, Timeline, TimelineOptions, TimelinePosition, TimelineStepOptions, UsaElement, UsaTimelineElement };
|
|
189
|
+
export { TIMELINE_PRESETS, configureComponents, defineTimeline, defineTimelineComponents, prefersReducedMotion, resolvePosition, supportsNativeScrub, timeline };
|
|
190
|
+
export type { ComponentsConfig, ScrubHandle, ScrubOptions, Timeline, TimelineOptions, TimelinePosition, TimelineStepOptions, UsaElement, UsaTimelineElement };
|
|
@@ -73,11 +73,29 @@ interface TimelineOptions {
|
|
|
73
73
|
onUpdate?: (progress: number) => void;
|
|
74
74
|
}
|
|
75
75
|
interface ScrubOptions {
|
|
76
|
-
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts. */
|
|
76
|
+
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts (JS engine only). */
|
|
77
77
|
offset?: number;
|
|
78
|
-
/** Smoothing 0–1 (0 = immediate, default 0). */
|
|
78
|
+
/** Smoothing 0–1 (0 = immediate, default 0). Smoothing needs the JS engine. */
|
|
79
79
|
smooth?: number;
|
|
80
|
+
/**
|
|
81
|
+
* 4.1: which progress source drives the timeline.
|
|
82
|
+
* - `'view'` (default): `source` moving through the viewport (CSS `ViewTimeline`, range `cover`).
|
|
83
|
+
* - `'scroll'`: the scroll position of `source` itself (a scroll container; CSS `ScrollTimeline`).
|
|
84
|
+
*/
|
|
85
|
+
source?: 'view' | 'scroll';
|
|
86
|
+
/** 4.1: `'auto'` (default) uses the browser's native scroll-driven animations when available, `'js'` forces the fallback. */
|
|
87
|
+
engine?: 'auto' | 'native' | 'js';
|
|
88
|
+
/** 4.1: scroll axis, `'block'` (default) · `'inline'` · `'x'` · `'y'`. */
|
|
89
|
+
axis?: 'block' | 'inline' | 'x' | 'y';
|
|
90
|
+
}
|
|
91
|
+
/** The function `scrub()` returns: call it to stop. `native` tells which engine runs it. */
|
|
92
|
+
interface ScrubHandle {
|
|
93
|
+
(): void;
|
|
94
|
+
/** `true` when the browser's ScrollTimeline / ViewTimeline drives it (compositor, no JS per frame). */
|
|
95
|
+
readonly native: boolean;
|
|
80
96
|
}
|
|
97
|
+
/** 4.1: whether `scrub()` can use native ScrollTimeline / ViewTimeline here. */
|
|
98
|
+
declare function supportsNativeScrub(source?: 'view' | 'scroll'): boolean;
|
|
81
99
|
interface Timeline {
|
|
82
100
|
/** Total length in ms. */
|
|
83
101
|
readonly duration: number;
|
|
@@ -100,8 +118,14 @@ interface Timeline {
|
|
|
100
118
|
seek(to: TimelinePosition): Timeline;
|
|
101
119
|
/** Get or set progress 0–1. */
|
|
102
120
|
progress(p?: number): number;
|
|
103
|
-
/**
|
|
104
|
-
|
|
121
|
+
/**
|
|
122
|
+
* Tie progress to scroll: `source` moving through the viewport (or, with
|
|
123
|
+
* `{ source: 'scroll' }`, a scroll container's own position). Runs on native
|
|
124
|
+
* ScrollTimeline / ViewTimeline when available (and no `smooth`, `offset`,
|
|
125
|
+
* `call()` cues or `onUpdate` need JS), else on a rAF-throttled listener.
|
|
126
|
+
* Returns a stop function with a `native` flag.
|
|
127
|
+
*/
|
|
128
|
+
scrub(source: Element, options?: ScrubOptions): ScrubHandle;
|
|
105
129
|
/** Stop and drop every animation (elements keep their last frame). */
|
|
106
130
|
cancel(): void;
|
|
107
131
|
}
|
|
@@ -133,7 +157,9 @@ declare function timeline(options?: TimelineOptions): Timeline;
|
|
|
133
157
|
* Attributes: `trigger` (`view` default · `click` · `manual`), `scrub`
|
|
134
158
|
* (progress follows scroll instead of playing), `overlap` (ms each step
|
|
135
159
|
* overlaps the previous, default 0), `duration` (600), `stagger` (ms),
|
|
136
|
-
* `repeat` (replay every time it enters the viewport).
|
|
160
|
+
* `repeat` (replay every time it enters the viewport). 4.1: `scrub` runs on native
|
|
161
|
+
* ScrollTimeline / ViewTimeline when supported (`data-native` is set); `scrub="js"`,
|
|
162
|
+
* `scrub="scroll"` and `smooth` tune it. Methods: `play()`,
|
|
137
163
|
* `reverse()`, `seek(t)`; property `timeline`. Event `usa:complete`.
|
|
138
164
|
* Reduced motion: steps appear in their final state.
|
|
139
165
|
*/
|
|
@@ -160,5 +186,5 @@ declare global {
|
|
|
160
186
|
}
|
|
161
187
|
}
|
|
162
188
|
|
|
163
|
-
export { TIMELINE_PRESETS, configureComponents, defineTimeline, defineTimelineComponents, prefersReducedMotion, resolvePosition, timeline };
|
|
164
|
-
export type { ComponentsConfig, ScrubOptions, Timeline, TimelineOptions, TimelinePosition, TimelineStepOptions, UsaElement, UsaTimelineElement };
|
|
189
|
+
export { TIMELINE_PRESETS, configureComponents, defineTimeline, defineTimelineComponents, prefersReducedMotion, resolvePosition, supportsNativeScrub, timeline };
|
|
190
|
+
export type { ComponentsConfig, ScrubHandle, ScrubOptions, Timeline, TimelineOptions, TimelinePosition, TimelineStepOptions, UsaElement, UsaTimelineElement };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { h as defineElement } from '../chunks/base-
|
|
2
|
-
export { a as configureComponents, p as prefersReducedMotion } from '../chunks/base-
|
|
3
|
-
import { t as timeline, T as TIMELINE_PRESETS } from '../chunks/core-
|
|
4
|
-
export { r as resolvePosition } from '../chunks/core-
|
|
1
|
+
import { h as defineElement } from '../chunks/base-BPG5zvex.js';
|
|
2
|
+
export { a as configureComponents, p as prefersReducedMotion } from '../chunks/base-BPG5zvex.js';
|
|
3
|
+
import { t as timeline, T as TIMELINE_PRESETS } from '../chunks/core-QTFk4kgO.js';
|
|
4
|
+
export { r as resolvePosition, s as supportsNativeScrub } from '../chunks/core-QTFk4kgO.js';
|
|
5
5
|
|
|
6
6
|
var css = "usa-timeline{display:block}usa-timeline[scrub]{position:relative}@media (prefers-reduced-motion:reduce){usa-timeline [data-tl]{opacity:1 !important;transform:none !important;filter:none !important;clip-path:none !important}}";
|
|
7
7
|
|
|
@@ -44,7 +44,13 @@ function defineTimeline(tag = 'usa-timeline') {
|
|
|
44
44
|
return;
|
|
45
45
|
}
|
|
46
46
|
if (this.flag('scrub')) {
|
|
47
|
-
|
|
47
|
+
// 4.1: native ScrollTimeline / ViewTimeline when available; `smooth`
|
|
48
|
+
// (0–0.95) or `scrub="js"` opt into the JS engine, `scrub="scroll"`
|
|
49
|
+
// follows this element's own scroll position.
|
|
50
|
+
const v = this.str('scrub');
|
|
51
|
+
const stop = tl.scrub(this, { smooth: this.num('smooth', 0), engine: v === 'js' ? 'js' : 'auto', source: v === 'scroll' ? 'scroll' : 'view' });
|
|
52
|
+
this.toggleAttribute('data-native', stop.native);
|
|
53
|
+
this.onCleanup(stop);
|
|
48
54
|
return;
|
|
49
55
|
}
|
|
50
56
|
const trigger = this.str('trigger', 'view');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"timeline.js","sources":["../../src/components/timeline/timeline-el.ts","../../src/components/timeline/index.ts"],"sourcesContent":["import { defineElement, type UsaElement } from '../base';\nimport { timeline, TIMELINE_PRESETS, type Timeline } from './core';\nimport css from './timeline.css?raw';\n\n/**\n * `<usa-timeline>` — declarative choreography. Every descendant with\n * `data-tl=\"<preset>\"` becomes a step, in document order; `data-at`\n * (`'-=200'`, `'<'`, `'label+=100'`, ms), `data-duration` and `data-label`\n * fine-tune it.\n *\n * Attributes: `trigger` (`view` default · `click` · `manual`), `scrub`\n * (progress follows scroll instead of playing), `overlap` (ms each step\n * overlaps the previous, default 0), `duration` (600), `stagger` (ms),\n * `repeat` (replay every time it enters the viewport). Methods: `play()`,\n * `reverse()`, `seek(t)`; property `timeline`. Event `usa:complete`.\n * Reduced motion: steps appear in their final state.\n */\nexport interface UsaTimelineElement extends UsaElement {\n readonly timeline: Timeline | null;\n play(): Promise<void>;\n reverse(): Promise<void>;\n seek(to: number | string): void;\n}\n\nexport function defineTimeline(tag = 'usa-timeline'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) =>\n class UsaTimeline extends Base {\n static get observedAttributes(): string[] {\n return ['scrub', 'trigger', 'overlap'];\n }\n private _tl: Timeline | null = null;\n\n get timeline(): Timeline | null {\n return this._tl;\n }\n\n play(): Promise<void> {\n return this._tl ? this._tl.play(0).then(() => void this.emit('complete')) : Promise.resolve();\n }\n\n reverse(): Promise<void> {\n return this._tl ? this._tl.reverse() : Promise.resolve();\n }\n\n seek(to: number | string): void {\n this._tl?.seek(to);\n }\n\n mount(): void {\n const overlap = this.num('overlap', 0);\n const tl = (this._tl = timeline({ defaults: { duration: this.num('duration', 600), stagger: this.num('stagger', 0) } }));\n this.querySelectorAll<HTMLElement>('[data-tl]').forEach((el, i) => {\n if (el.dataset.label) tl.label(el.dataset.label);\n const name = el.dataset.tl || 'fade';\n tl.to(el, TIMELINE_PRESETS[name] ? name : 'fade', {\n at: el.dataset.at ?? (i && overlap ? `-=${overlap}` : undefined),\n duration: el.dataset.duration ? Number(el.dataset.duration) : undefined,\n });\n });\n this.onCleanup(() => tl.cancel());\n if (this.reduced) {\n tl.seek(tl.duration);\n return;\n }\n if (this.flag('scrub')) {\n this.
|
|
1
|
+
{"version":3,"file":"timeline.js","sources":["../../src/components/timeline/timeline-el.ts","../../src/components/timeline/index.ts"],"sourcesContent":["import { defineElement, type UsaElement } from '../base';\nimport { timeline, TIMELINE_PRESETS, type Timeline } from './core';\nimport css from './timeline.css?raw';\n\n/**\n * `<usa-timeline>` — declarative choreography. Every descendant with\n * `data-tl=\"<preset>\"` becomes a step, in document order; `data-at`\n * (`'-=200'`, `'<'`, `'label+=100'`, ms), `data-duration` and `data-label`\n * fine-tune it.\n *\n * Attributes: `trigger` (`view` default · `click` · `manual`), `scrub`\n * (progress follows scroll instead of playing), `overlap` (ms each step\n * overlaps the previous, default 0), `duration` (600), `stagger` (ms),\n * `repeat` (replay every time it enters the viewport). 4.1: `scrub` runs on native\n * ScrollTimeline / ViewTimeline when supported (`data-native` is set); `scrub=\"js\"`,\n * `scrub=\"scroll\"` and `smooth` tune it. Methods: `play()`,\n * `reverse()`, `seek(t)`; property `timeline`. Event `usa:complete`.\n * Reduced motion: steps appear in their final state.\n */\nexport interface UsaTimelineElement extends UsaElement {\n readonly timeline: Timeline | null;\n play(): Promise<void>;\n reverse(): Promise<void>;\n seek(to: number | string): void;\n}\n\nexport function defineTimeline(tag = 'usa-timeline'): CustomElementConstructor | undefined {\n return defineElement(\n tag,\n (Base) =>\n class UsaTimeline extends Base {\n static get observedAttributes(): string[] {\n return ['scrub', 'trigger', 'overlap'];\n }\n private _tl: Timeline | null = null;\n\n get timeline(): Timeline | null {\n return this._tl;\n }\n\n play(): Promise<void> {\n return this._tl ? this._tl.play(0).then(() => void this.emit('complete')) : Promise.resolve();\n }\n\n reverse(): Promise<void> {\n return this._tl ? this._tl.reverse() : Promise.resolve();\n }\n\n seek(to: number | string): void {\n this._tl?.seek(to);\n }\n\n mount(): void {\n const overlap = this.num('overlap', 0);\n const tl = (this._tl = timeline({ defaults: { duration: this.num('duration', 600), stagger: this.num('stagger', 0) } }));\n this.querySelectorAll<HTMLElement>('[data-tl]').forEach((el, i) => {\n if (el.dataset.label) tl.label(el.dataset.label);\n const name = el.dataset.tl || 'fade';\n tl.to(el, TIMELINE_PRESETS[name] ? name : 'fade', {\n at: el.dataset.at ?? (i && overlap ? `-=${overlap}` : undefined),\n duration: el.dataset.duration ? Number(el.dataset.duration) : undefined,\n });\n });\n this.onCleanup(() => tl.cancel());\n if (this.reduced) {\n tl.seek(tl.duration);\n return;\n }\n if (this.flag('scrub')) {\n // 4.1: native ScrollTimeline / ViewTimeline when available; `smooth`\n // (0–0.95) or `scrub=\"js\"` opt into the JS engine, `scrub=\"scroll\"`\n // follows this element's own scroll position.\n const v = this.str('scrub');\n const stop = tl.scrub(this, { smooth: this.num('smooth', 0), engine: v === 'js' ? 'js' : 'auto', source: v === 'scroll' ? 'scroll' : 'view' });\n this.toggleAttribute('data-native', stop.native);\n this.onCleanup(stop);\n return;\n }\n const trigger = this.str('trigger', 'view');\n if (trigger === 'click') {\n // 4.0.1: show the finished composition until the first click\n // (it used to sit invisible at t=0); Enter / Space replay it too.\n tl.seek(tl.duration);\n this.listen(this, 'click', () => void this.play());\n this.listen(this, 'keydown', (e: KeyboardEvent) => {\n if (e.target === this && (e.key === 'Enter' || e.key === ' ')) {\n e.preventDefault();\n void this.play();\n }\n });\n if (!this.hasAttribute('tabindex')) this.tabIndex = 0;\n return;\n }\n tl.seek(0);\n if (trigger === 'view') {\n let played = false;\n this.inView((v) => {\n if (v && (!played || this.flag('repeat'))) {\n played = true;\n void this.play();\n } else if (!v && this.flag('repeat')) tl.seek(0);\n }, { threshold: 0.2 });\n }\n }\n\n unmount(): void {\n this._tl = null;\n }\n },\n { id: 'timeline', text: css }\n );\n}\n","/**\n * use-scroll-animate/components/timeline — choreography (v3.1).\n * `timeline()` chains, overlaps, labels, seeks, reverses and scroll-scrubs\n * WAAPI animations on one playhead; `<usa-timeline>` builds one from\n * `data-tl` children.\n */\nimport { defineTimeline, type UsaTimelineElement } from './timeline-el';\n\nexport { defineTimeline };\nexport { timeline, resolvePosition, TIMELINE_PRESETS, supportsNativeScrub } from './core';\nexport type { Timeline, TimelineOptions, TimelineStepOptions, TimelinePosition, ScrubOptions, ScrubHandle } from './core';\nexport type { UsaTimelineElement };\nexport { configureComponents, prefersReducedMotion } from '../base';\nexport type { ComponentsConfig, UsaElement } from '../base';\n\n/** Register every component of this category under its default tag. */\nexport function defineTimelineComponents(): void {\n defineTimeline();\n}\n\ndeclare global {\n interface HTMLElementTagNameMap {\n 'usa-timeline': UsaTimelineElement;\n }\n}\n"],"names":[],"mappings":";;;;;;;AA0BM,SAAU,cAAc,CAAC,GAAG,GAAG,cAAc,EAAA;AACjD,IAAA,OAAO,aAAa,CAClB,GAAG,EACH,CAAC,IAAI,KACH,MAAM,WAAY,SAAQ,IAAI,CAAA;AAA9B,QAAA,WAAA,GAAA;;YAIU,IAAA,CAAA,GAAG,GAAoB,IAAI;QA0ErC;AA7EE,QAAA,WAAW,kBAAkB,GAAA;AAC3B,YAAA,OAAO,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC;QACxC;AAGA,QAAA,IAAI,QAAQ,GAAA;YACV,OAAO,IAAI,CAAC,GAAG;QACjB;QAEA,IAAI,GAAA;AACF,YAAA,OAAO,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,IAAI,CAAC,MAAM,KAAK,IAAI,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC,GAAG,OAAO,CAAC,OAAO,EAAE;QAC/F;QAEA,OAAO,GAAA;AACL,YAAA,OAAO,IAAI,CAAC,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,OAAO,EAAE;QAC1D;AAEA,QAAA,IAAI,CAAC,EAAmB,EAAA;AACtB,YAAA,IAAI,CAAC,GAAG,EAAE,IAAI,CAAC,EAAE,CAAC;QACpB;QAEA,KAAK,GAAA;YACH,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;AACtC,YAAA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C,MAAM,CAAC,CAAC,CAAC,KAAI;AAChB,oBAAA,IAAI,CAAC,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,CAAC,EAAE;wBACzC,MAAM,GAAG,IAAI;AACb,wBAAA,KAAK,IAAI,CAAC,IAAI,EAAE;oBAClB;yBAAO,IAAI,CAAC,CAAC,IAAI,IAAI,CAAC,IAAI,CAAC,QAAQ,CAAC;AAAE,wBAAA,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;AAClD,gBAAA,CAAC,EAAE,EAAE,SAAS,EAAE,GAAG,EAAE,CAAC;YACxB;QACF;QAEA,OAAO,GAAA;AACL,YAAA,IAAI,CAAC,GAAG,GAAG,IAAI;QACjB;KACD,EACH,EAAE,EAAE,EAAE,UAAU,EAAE,IAAI,EAAE,GAAG,EAAE,CAC9B;AACH;;AC/GA;;;;;AAKG;AAUH;SACgB,wBAAwB,GAAA;AACtC,IAAA,cAAc,EAAE;AAClB;;;;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { h as defineElement, k as kindOf, s as shadowStyles, i as EASE_OUT, F as FLUENT_DECELERATE, p as prefersReducedMotion } from '../chunks/base-
|
|
2
|
-
export { a as configureComponents } from '../chunks/base-
|
|
1
|
+
import { h as defineElement, k as kindOf, s as shadowStyles, i as EASE_OUT, F as FLUENT_DECELERATE, p as prefersReducedMotion } from '../chunks/base-BPG5zvex.js';
|
|
2
|
+
export { a as configureComponents } from '../chunks/base-BPG5zvex.js';
|
|
3
3
|
|
|
4
4
|
var shadowCss = ":host{display:contents}dialog{position:fixed;inset:0;width:100%;height:100%;max-width:none;max-height:none;margin:0;padding:0;border:0;background:transparent;color:inherit;overflow:hidden}dialog:not([open]){display:none}dialog::backdrop{background:transparent}[part=\"backdrop\"]{position:absolute;inset:0;background:var(--usa-dialog-backdrop,rgb(0 0 0 / 0.42))}[part=\"panel\"]{position:absolute;left:50%;top:50%;translate:-50% -50%;box-sizing:border-box;width:min(var(--usa-dialog-width,480px),calc(100vw - 32px));max-height:calc(100vh - 32px);overflow:auto;padding:var(--usa-dialog-padding,24px);border-radius:var(--usa-dialog-radius,12px);background:var(--usa-dialog-bg,Canvas);color:var(--usa-dialog-fg,CanvasText);box-shadow:0 32px 64px -12px rgb(0 0 0 / 0.45),0 0 0 1px rgb(127 127 127 / 0.18)}dialog[data-kind^=\"drawer\"] [part=\"panel\"]{top:0;bottom:0;translate:none;max-height:none;height:100%;border-radius:0;width:min(var(--usa-dialog-width,380px),88vw)}dialog[data-kind=\"drawer-start\"] [part=\"panel\"]{left:0}dialog[data-kind=\"drawer-end\"] [part=\"panel\"]{left:auto;right:0}dialog[data-kind=\"drawer-bottom\"] [part=\"panel\"],dialog[data-kind=\"sheet\"] [part=\"panel\"]{top:auto;bottom:0;left:0;right:0;translate:none;width:100%;height:auto;max-height:85vh;border-radius:var(--usa-dialog-radius,16px) var(--usa-dialog-radius,16px) 0 0}dialog[data-kind=\"sheet\"] [part=\"panel\"]{left:50%;translate:-50% 0;width:min(var(--usa-dialog-width,560px),100vw)}";
|
|
5
5
|
|
package/dist/components/ui.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { h as defineElement,
|
|
2
|
-
export { a as configureComponents, p as prefersReducedMotion } from '../chunks/base-
|
|
3
|
-
import { d as springEasing, c as createSpring, p as projectInertia, s as snapTo, a as rubberBand } from '../chunks/spring-
|
|
4
|
-
import { a as adoptVariants } from '../chunks/variants-
|
|
5
|
-
export { V as VARIANTS, s as setVariant } from '../chunks/variants-
|
|
1
|
+
import { h as defineElement, b as clamp, d as caf, r as raf } from '../chunks/base-BPG5zvex.js';
|
|
2
|
+
export { a as configureComponents, p as prefersReducedMotion } from '../chunks/base-BPG5zvex.js';
|
|
3
|
+
import { d as springEasing, c as createSpring, p as projectInertia, s as snapTo, a as rubberBand } from '../chunks/spring-BziPsW3r.js';
|
|
4
|
+
import { a as adoptVariants } from '../chunks/variants-BVYMcxRv.js';
|
|
5
|
+
export { V as VARIANTS, s as setVariant } from '../chunks/variants-BVYMcxRv.js';
|
|
6
6
|
|
|
7
7
|
/** Position a fixed `floating` element next to `anchor`, flipping when it would leave the viewport. */
|
|
8
8
|
function place(floating, anchor, placement = 'top', gap = 8) {
|
package/dist/components/vue.cjs
CHANGED
|
@@ -16,7 +16,7 @@ require('./click.cjs');
|
|
|
16
16
|
require('./ui.cjs');
|
|
17
17
|
require('./page.cjs');
|
|
18
18
|
require('./timeline.cjs');
|
|
19
|
-
require('../chunks/core-
|
|
19
|
+
require('../chunks/core-CLu8ZrC-.cjs');
|
|
20
20
|
require('./gesture.cjs');
|
|
21
21
|
require('../chunks/core-IaorbTdu.cjs');
|
|
22
22
|
require('./svg.cjs');
|
|
@@ -1295,10 +1295,26 @@ interface TimelineStepOptions {
|
|
|
1295
1295
|
stagger?: number;
|
|
1296
1296
|
}
|
|
1297
1297
|
interface ScrubOptions {
|
|
1298
|
-
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts. */
|
|
1298
|
+
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts (JS engine only). */
|
|
1299
1299
|
offset?: number;
|
|
1300
|
-
/** Smoothing 0–1 (0 = immediate, default 0). */
|
|
1300
|
+
/** Smoothing 0–1 (0 = immediate, default 0). Smoothing needs the JS engine. */
|
|
1301
1301
|
smooth?: number;
|
|
1302
|
+
/**
|
|
1303
|
+
* 4.1: which progress source drives the timeline.
|
|
1304
|
+
* - `'view'` (default): `source` moving through the viewport (CSS `ViewTimeline`, range `cover`).
|
|
1305
|
+
* - `'scroll'`: the scroll position of `source` itself (a scroll container; CSS `ScrollTimeline`).
|
|
1306
|
+
*/
|
|
1307
|
+
source?: 'view' | 'scroll';
|
|
1308
|
+
/** 4.1: `'auto'` (default) uses the browser's native scroll-driven animations when available, `'js'` forces the fallback. */
|
|
1309
|
+
engine?: 'auto' | 'native' | 'js';
|
|
1310
|
+
/** 4.1: scroll axis, `'block'` (default) · `'inline'` · `'x'` · `'y'`. */
|
|
1311
|
+
axis?: 'block' | 'inline' | 'x' | 'y';
|
|
1312
|
+
}
|
|
1313
|
+
/** The function `scrub()` returns: call it to stop. `native` tells which engine runs it. */
|
|
1314
|
+
interface ScrubHandle {
|
|
1315
|
+
(): void;
|
|
1316
|
+
/** `true` when the browser's ScrollTimeline / ViewTimeline drives it (compositor, no JS per frame). */
|
|
1317
|
+
readonly native: boolean;
|
|
1302
1318
|
}
|
|
1303
1319
|
interface Timeline {
|
|
1304
1320
|
/** Total length in ms. */
|
|
@@ -1322,8 +1338,14 @@ interface Timeline {
|
|
|
1322
1338
|
seek(to: TimelinePosition): Timeline;
|
|
1323
1339
|
/** Get or set progress 0–1. */
|
|
1324
1340
|
progress(p?: number): number;
|
|
1325
|
-
/**
|
|
1326
|
-
|
|
1341
|
+
/**
|
|
1342
|
+
* Tie progress to scroll: `source` moving through the viewport (or, with
|
|
1343
|
+
* `{ source: 'scroll' }`, a scroll container's own position). Runs on native
|
|
1344
|
+
* ScrollTimeline / ViewTimeline when available (and no `smooth`, `offset`,
|
|
1345
|
+
* `call()` cues or `onUpdate` need JS), else on a rAF-throttled listener.
|
|
1346
|
+
* Returns a stop function with a `native` flag.
|
|
1347
|
+
*/
|
|
1348
|
+
scrub(source: Element, options?: ScrubOptions): ScrubHandle;
|
|
1327
1349
|
/** Stop and drop every animation (elements keep their last frame). */
|
|
1328
1350
|
cancel(): void;
|
|
1329
1351
|
}
|
|
@@ -1337,7 +1359,9 @@ interface Timeline {
|
|
|
1337
1359
|
* Attributes: `trigger` (`view` default · `click` · `manual`), `scrub`
|
|
1338
1360
|
* (progress follows scroll instead of playing), `overlap` (ms each step
|
|
1339
1361
|
* overlaps the previous, default 0), `duration` (600), `stagger` (ms),
|
|
1340
|
-
* `repeat` (replay every time it enters the viewport).
|
|
1362
|
+
* `repeat` (replay every time it enters the viewport). 4.1: `scrub` runs on native
|
|
1363
|
+
* ScrollTimeline / ViewTimeline when supported (`data-native` is set); `scrub="js"`,
|
|
1364
|
+
* `scrub="scroll"` and `smooth` tune it. Methods: `play()`,
|
|
1341
1365
|
* `reverse()`, `seek(t)`; property `timeline`. Event `usa:complete`.
|
|
1342
1366
|
* Reduced motion: steps appear in their final state.
|
|
1343
1367
|
*/
|
package/dist/components/vue.d.ts
CHANGED
|
@@ -1295,10 +1295,26 @@ interface TimelineStepOptions {
|
|
|
1295
1295
|
stagger?: number;
|
|
1296
1296
|
}
|
|
1297
1297
|
interface ScrubOptions {
|
|
1298
|
-
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts. */
|
|
1298
|
+
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts (JS engine only). */
|
|
1299
1299
|
offset?: number;
|
|
1300
|
-
/** Smoothing 0–1 (0 = immediate, default 0). */
|
|
1300
|
+
/** Smoothing 0–1 (0 = immediate, default 0). Smoothing needs the JS engine. */
|
|
1301
1301
|
smooth?: number;
|
|
1302
|
+
/**
|
|
1303
|
+
* 4.1: which progress source drives the timeline.
|
|
1304
|
+
* - `'view'` (default): `source` moving through the viewport (CSS `ViewTimeline`, range `cover`).
|
|
1305
|
+
* - `'scroll'`: the scroll position of `source` itself (a scroll container; CSS `ScrollTimeline`).
|
|
1306
|
+
*/
|
|
1307
|
+
source?: 'view' | 'scroll';
|
|
1308
|
+
/** 4.1: `'auto'` (default) uses the browser's native scroll-driven animations when available, `'js'` forces the fallback. */
|
|
1309
|
+
engine?: 'auto' | 'native' | 'js';
|
|
1310
|
+
/** 4.1: scroll axis, `'block'` (default) · `'inline'` · `'x'` · `'y'`. */
|
|
1311
|
+
axis?: 'block' | 'inline' | 'x' | 'y';
|
|
1312
|
+
}
|
|
1313
|
+
/** The function `scrub()` returns: call it to stop. `native` tells which engine runs it. */
|
|
1314
|
+
interface ScrubHandle {
|
|
1315
|
+
(): void;
|
|
1316
|
+
/** `true` when the browser's ScrollTimeline / ViewTimeline drives it (compositor, no JS per frame). */
|
|
1317
|
+
readonly native: boolean;
|
|
1302
1318
|
}
|
|
1303
1319
|
interface Timeline {
|
|
1304
1320
|
/** Total length in ms. */
|
|
@@ -1322,8 +1338,14 @@ interface Timeline {
|
|
|
1322
1338
|
seek(to: TimelinePosition): Timeline;
|
|
1323
1339
|
/** Get or set progress 0–1. */
|
|
1324
1340
|
progress(p?: number): number;
|
|
1325
|
-
/**
|
|
1326
|
-
|
|
1341
|
+
/**
|
|
1342
|
+
* Tie progress to scroll: `source` moving through the viewport (or, with
|
|
1343
|
+
* `{ source: 'scroll' }`, a scroll container's own position). Runs on native
|
|
1344
|
+
* ScrollTimeline / ViewTimeline when available (and no `smooth`, `offset`,
|
|
1345
|
+
* `call()` cues or `onUpdate` need JS), else on a rAF-throttled listener.
|
|
1346
|
+
* Returns a stop function with a `native` flag.
|
|
1347
|
+
*/
|
|
1348
|
+
scrub(source: Element, options?: ScrubOptions): ScrubHandle;
|
|
1327
1349
|
/** Stop and drop every animation (elements keep their last frame). */
|
|
1328
1350
|
cancel(): void;
|
|
1329
1351
|
}
|
|
@@ -1337,7 +1359,9 @@ interface Timeline {
|
|
|
1337
1359
|
* Attributes: `trigger` (`view` default · `click` · `manual`), `scrub`
|
|
1338
1360
|
* (progress follows scroll instead of playing), `overlap` (ms each step
|
|
1339
1361
|
* overlaps the previous, default 0), `duration` (600), `stagger` (ms),
|
|
1340
|
-
* `repeat` (replay every time it enters the viewport).
|
|
1362
|
+
* `repeat` (replay every time it enters the viewport). 4.1: `scrub` runs on native
|
|
1363
|
+
* ScrollTimeline / ViewTimeline when supported (`data-native` is set); `scrub="js"`,
|
|
1364
|
+
* `scrub="scroll"` and `smooth` tune it. Methods: `play()`,
|
|
1341
1365
|
* `reverse()`, `seek(t)`; property `timeline`. Event `usa:complete`.
|
|
1342
1366
|
* Reduced motion: steps appear in their final state.
|
|
1343
1367
|
*/
|