use-scroll-animate 4.0.1 → 4.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/dist/chunks/{base-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-BRIIoKeS.cjs} +55 -12
- package/dist/chunks/core-BRIIoKeS.cjs.map +1 -0
- package/dist/chunks/{core-Co-6AL0h.js → core-LkGRmgES.js} +56 -14
- package/dist/chunks/core-LkGRmgES.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 +2 -1
- package/dist/components/angular.cjs.map +1 -1
- package/dist/components/angular.d.cts +32 -8
- package/dist/components/angular.d.ts +32 -8
- package/dist/components/angular.js +6 -5
- package/dist/components/angular.js.map +1 -1
- package/dist/components/background.js +3 -3
- package/dist/components/cards.js +3 -3
- package/dist/components/click.js +3 -3
- package/dist/components/depth.js +4 -4
- package/dist/components/feedback.js +2 -2
- package/dist/components/gesture.js +5 -5
- package/dist/components/interaction.js +2 -2
- package/dist/components/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 +2 -1
- package/dist/components/solid.cjs.map +1 -1
- package/dist/components/solid.d.cts +32 -8
- package/dist/components/solid.d.ts +32 -8
- package/dist/components/solid.js +6 -5
- package/dist/components/solid.js.map +1 -1
- package/dist/components/svelte.cjs +2 -1
- package/dist/components/svelte.cjs.map +1 -1
- package/dist/components/svelte.d.cts +32 -8
- package/dist/components/svelte.d.ts +32 -8
- package/dist/components/svelte.js +6 -5
- package/dist/components/svelte.js.map +1 -1
- package/dist/components/svg.js +2 -2
- package/dist/components/text.js +2 -2
- package/dist/components/timeline.cjs +10 -2
- package/dist/components/timeline.cjs.map +1 -1
- package/dist/components/timeline.d.cts +36 -10
- package/dist/components/timeline.d.ts +36 -10
- package/dist/components/timeline.js +12 -5
- package/dist/components/timeline.js.map +1 -1
- package/dist/components/tokens.cjs +226 -0
- package/dist/components/tokens.cjs.map +1 -0
- package/dist/components/tokens.d.cts +74 -0
- package/dist/components/tokens.d.ts +74 -0
- package/dist/components/tokens.js +211 -0
- package/dist/components/tokens.js.map +1 -0
- package/dist/components/transitions.js +2 -2
- package/dist/components/ui.js +5 -5
- package/dist/components/vue.cjs +2 -1
- package/dist/components/vue.cjs.map +1 -1
- package/dist/components/vue.d.cts +32 -8
- package/dist/components/vue.d.ts +32 -8
- package/dist/components/vue.js +6 -5
- package/dist/components/vue.js.map +1 -1
- package/dist/components/webgl.js +2 -2
- package/dist/components.cjs +17 -1
- package/dist/components.cjs.map +1 -1
- package/dist/components.d.cts +109 -11
- package/dist/components.d.ts +109 -11
- package/dist/components.js +8 -7
- package/dist/components.js.map +1 -1
- package/dist/components.umd.js +2 -2
- package/dist/components.umd.js.map +1 -1
- package/dist/index.cjs +3 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +33 -9
- package/dist/index.d.ts +33 -9
- package/dist/index.js +3 -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 +2 -2
- package/docs/motion-tokens.css +31 -0
- package/docs/motion-tokens.md +46 -0
- package/docs/motion.tokens.json +132 -0
- package/package.json +11 -1
- package/dist/chunks/core-Co-6AL0h.js.map +0 -1
- package/dist/chunks/core-DXqZm5Il.cjs.map +0 -1
|
@@ -1285,9 +1285,9 @@ declare global {
|
|
|
1285
1285
|
*/
|
|
1286
1286
|
type TimelinePosition = number | string;
|
|
1287
1287
|
interface TimelineStepOptions {
|
|
1288
|
-
/** Duration in ms (
|
|
1289
|
-
duration?: number;
|
|
1290
|
-
/** CSS easing (
|
|
1288
|
+
/** Duration in ms or a motion token name (`'fast'`, `'slow'`…; 4.2). Default: timeline default, 600. */
|
|
1289
|
+
duration?: number | string;
|
|
1290
|
+
/** CSS easing or a motion token name (`'emphasized'`, `'spring'`…; 4.2). Default `cubic-bezier(0.22, 1, 0.36, 1)`. */
|
|
1291
1291
|
easing?: string;
|
|
1292
1292
|
/** Start position, see `TimelinePosition`. */
|
|
1293
1293
|
at?: TimelinePosition;
|
|
@@ -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
|
*/
|
|
@@ -1285,9 +1285,9 @@ declare global {
|
|
|
1285
1285
|
*/
|
|
1286
1286
|
type TimelinePosition = number | string;
|
|
1287
1287
|
interface TimelineStepOptions {
|
|
1288
|
-
/** Duration in ms (
|
|
1289
|
-
duration?: number;
|
|
1290
|
-
/** CSS easing (
|
|
1288
|
+
/** Duration in ms or a motion token name (`'fast'`, `'slow'`…; 4.2). Default: timeline default, 600. */
|
|
1289
|
+
duration?: number | string;
|
|
1290
|
+
/** CSS easing or a motion token name (`'emphasized'`, `'spring'`…; 4.2). Default `cubic-bezier(0.22, 1, 0.36, 1)`. */
|
|
1291
1291
|
easing?: string;
|
|
1292
1292
|
/** Start position, see `TimelinePosition`. */
|
|
1293
1293
|
at?: TimelinePosition;
|
|
@@ -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/solid.js
CHANGED
|
@@ -3,23 +3,24 @@ import { defineComponents } from '../components.js';
|
|
|
3
3
|
import { b as bindUsa } from '../chunks/bind-B_CTL6Qn.js';
|
|
4
4
|
export { u as usaEventName } from '../chunks/bind-B_CTL6Qn.js';
|
|
5
5
|
import './reveal.js';
|
|
6
|
-
import '../chunks/base-
|
|
6
|
+
import '../chunks/base-BPG5zvex.js';
|
|
7
7
|
import './text.js';
|
|
8
8
|
import './interaction.js';
|
|
9
9
|
import './feedback.js';
|
|
10
10
|
import './background.js';
|
|
11
|
-
import '../chunks/variants-
|
|
11
|
+
import '../chunks/variants-BVYMcxRv.js';
|
|
12
12
|
import './transitions.js';
|
|
13
13
|
import './physics.js';
|
|
14
|
-
import '../chunks/spring-
|
|
14
|
+
import '../chunks/spring-BziPsW3r.js';
|
|
15
15
|
import './cards.js';
|
|
16
16
|
import './click.js';
|
|
17
17
|
import './ui.js';
|
|
18
18
|
import './page.js';
|
|
19
19
|
import './timeline.js';
|
|
20
|
-
import '../chunks/core-
|
|
20
|
+
import '../chunks/core-LkGRmgES.js';
|
|
21
|
+
import './tokens.js';
|
|
21
22
|
import './gesture.js';
|
|
22
|
-
import '../chunks/core-
|
|
23
|
+
import '../chunks/core-eXX8rB_b.js';
|
|
23
24
|
import './svg.js';
|
|
24
25
|
import './webgl.js';
|
|
25
26
|
import './depth.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"solid.js","sources":["../../src/components/frameworks/solid.ts"],"sourcesContent":["/**\n * use-scroll-animate/components/solid — Solid integration (v3.8).\n * Solid renders custom elements natively: set properties with `prop:` and\n * listen with `on:` (`<usa-toggle prop:checked={on()} on:usa:change={…}>`).\n * This entry adds `defineUsa()` (client only, SolidStart-safe), a `usa`\n * directive for `use:usa={{ props, on }}`, and JSX types.\n *\n * ```tsx\n * import { defineUsa, usa } from 'use-scroll-animate/components/solid';\n * import type {} from 'use-scroll-animate/components/solid'; // JSX types\n * onMount(() => defineUsa());\n * false && usa; // keep the directive import (Solid convention)\n * <usa-card use:usa={{ on: { flip: (e) => console.log(e.detail) } }} effect=\"flip\">…</usa-card>\n * ```\n */\nimport { createRenderEffect, onCleanup } from 'solid-js';\nimport { defineComponents, type ComponentCategory } from '../index';\nimport { bindUsa, type UsaBinding } from './bind';\nimport type { UsaIntrinsicElements } from './jsx';\n\nexport { bindUsa, usaEventName } from './bind';\nexport type { UsaBinding } from './bind';\n\n/**\n * Solid directive (`use:usa`). Solid calls it with the element and an\n * accessor; since 4.0.1 the binding is tracked with `createRenderEffect`, so\n * signals read inside `{{ props, on }}` update the element automatically and\n * the listeners are removed on cleanup. `refresh()` is kept for code that\n * calls the directive outside a reactive owner.\n */\nexport function usa(el: HTMLElement, accessor: () => UsaBinding | undefined): { refresh(): void; destroy(): void } {\n let b: ReturnType<typeof bindUsa> | null = null;\n const run = () => {\n const v = accessor() || {};\n if (b) b.update(v);\n else b = bindUsa(el, v);\n };\n createRenderEffect(run);\n if (!b) run();\n const destroy = () => b?.destroy();\n onCleanup(destroy);\n return { refresh: run, destroy };\n}\n\n/** Register the elements (all, or some categories) — call from `onMount` in SSR apps. */\nexport function defineUsa(categories?: ComponentCategory[]): void {\n if (typeof window !== 'undefined') defineComponents(categories);\n}\n\n/** JSX intrinsic elements for Solid (same attribute types as the React/Preact ones). */\nexport type SolidUsaIntrinsicElements = UsaIntrinsicElements;\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"solid.js","sources":["../../src/components/frameworks/solid.ts"],"sourcesContent":["/**\n * use-scroll-animate/components/solid — Solid integration (v3.8).\n * Solid renders custom elements natively: set properties with `prop:` and\n * listen with `on:` (`<usa-toggle prop:checked={on()} on:usa:change={…}>`).\n * This entry adds `defineUsa()` (client only, SolidStart-safe), a `usa`\n * directive for `use:usa={{ props, on }}`, and JSX types.\n *\n * ```tsx\n * import { defineUsa, usa } from 'use-scroll-animate/components/solid';\n * import type {} from 'use-scroll-animate/components/solid'; // JSX types\n * onMount(() => defineUsa());\n * false && usa; // keep the directive import (Solid convention)\n * <usa-card use:usa={{ on: { flip: (e) => console.log(e.detail) } }} effect=\"flip\">…</usa-card>\n * ```\n */\nimport { createRenderEffect, onCleanup } from 'solid-js';\nimport { defineComponents, type ComponentCategory } from '../index';\nimport { bindUsa, type UsaBinding } from './bind';\nimport type { UsaIntrinsicElements } from './jsx';\n\nexport { bindUsa, usaEventName } from './bind';\nexport type { UsaBinding } from './bind';\n\n/**\n * Solid directive (`use:usa`). Solid calls it with the element and an\n * accessor; since 4.0.1 the binding is tracked with `createRenderEffect`, so\n * signals read inside `{{ props, on }}` update the element automatically and\n * the listeners are removed on cleanup. `refresh()` is kept for code that\n * calls the directive outside a reactive owner.\n */\nexport function usa(el: HTMLElement, accessor: () => UsaBinding | undefined): { refresh(): void; destroy(): void } {\n let b: ReturnType<typeof bindUsa> | null = null;\n const run = () => {\n const v = accessor() || {};\n if (b) b.update(v);\n else b = bindUsa(el, v);\n };\n createRenderEffect(run);\n if (!b) run();\n const destroy = () => b?.destroy();\n onCleanup(destroy);\n return { refresh: run, destroy };\n}\n\n/** Register the elements (all, or some categories) — call from `onMount` in SSR apps. */\nexport function defineUsa(categories?: ComponentCategory[]): void {\n if (typeof window !== 'undefined') defineComponents(categories);\n}\n\n/** JSX intrinsic elements for Solid (same attribute types as the React/Preact ones). */\nexport type SolidUsaIntrinsicElements = UsaIntrinsicElements;\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;AAcG;AASH;;;;;;AAMG;AACG,SAAU,GAAG,CAAC,EAAe,EAAE,QAAsC,EAAA;IACzE,IAAI,CAAC,GAAsC,IAAI;IAC/C,MAAM,GAAG,GAAG,MAAK;AACf,QAAA,MAAM,CAAC,GAAG,QAAQ,EAAE,IAAI,EAAE;AAC1B,QAAA,IAAI,CAAC;AAAE,YAAA,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;;AACb,YAAA,CAAC,GAAG,OAAO,CAAC,EAAE,EAAE,CAAC,CAAC;AACzB,IAAA,CAAC;IACD,kBAAkB,CAAC,GAAG,CAAC;AACvB,IAAA,IAAI,CAAC,CAAC;AAAE,QAAA,GAAG,EAAE;IACb,MAAM,OAAO,GAAG,MAAM,CAAC,EAAE,OAAO,EAAE;IAClC,SAAS,CAAC,OAAO,CAAC;AAClB,IAAA,OAAO,EAAE,OAAO,EAAE,GAAG,EAAE,OAAO,EAAE;AAClC;AAEA;AACM,SAAU,SAAS,CAAC,UAAgC,EAAA;IACxD,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,gBAAgB,CAAC,UAAU,CAAC;AACjE;;;;"}
|
|
@@ -17,7 +17,8 @@ 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-BRIIoKeS.cjs');
|
|
21
|
+
require('./tokens.cjs');
|
|
21
22
|
require('./gesture.cjs');
|
|
22
23
|
require('../chunks/core-IaorbTdu.cjs');
|
|
23
24
|
require('./svg.cjs');
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svelte.cjs","sources":["../../src/components/frameworks/svelte.ts"],"sourcesContent":["/**\n * use-scroll-animate/components/svelte — Svelte integration (v3.8).\n * Svelte (3, 4, 5) renders `<usa-*>` tags natively; `use:usa` sets\n * **properties** and `usa:*` listeners in one place, and `defineUsa()`\n * registers the elements on the client only (safe in SvelteKit SSR).\n *\n * ```svelte\n * <script>\n * import { usa, defineUsa } from 'use-scroll-animate/components/svelte';\n * import { onMount } from 'svelte';\n * onMount(() => defineUsa(['click', 'ui']));\n * let on = false;\n * </script>\n * <usa-toggle use:usa={{ props: { checked: on }, on: { change: (e) => (on = e.detail.checked) } }}></usa-toggle>\n * ```\n * Plain `on:usa:change` does not compile in Svelte 3/4 (colon); use the action or `onusa:change` in Svelte 5.\n */\nimport { defineComponents, type ComponentCategory } from '../index';\nimport { bindUsa, type UsaBinding } from './bind';\n\nexport { bindUsa, usaEventName } from './bind';\nexport type { UsaBinding } from './bind';\n\n/** Svelte action: `use:usa={{ props, on }}`. */\nexport function usa(node: HTMLElement, binding: UsaBinding = {}): { update(b: UsaBinding): void; destroy(): void } {\n return bindUsa(node, binding);\n}\n\n/** Register the elements (all, or some categories) — call from `onMount` for SSR apps. */\nexport function defineUsa(categories?: ComponentCategory[]): void {\n if (typeof window !== 'undefined') defineComponents(categories);\n}\n"],"names":["bindUsa","defineComponents"],"mappings":"
|
|
1
|
+
{"version":3,"file":"svelte.cjs","sources":["../../src/components/frameworks/svelte.ts"],"sourcesContent":["/**\n * use-scroll-animate/components/svelte — Svelte integration (v3.8).\n * Svelte (3, 4, 5) renders `<usa-*>` tags natively; `use:usa` sets\n * **properties** and `usa:*` listeners in one place, and `defineUsa()`\n * registers the elements on the client only (safe in SvelteKit SSR).\n *\n * ```svelte\n * <script>\n * import { usa, defineUsa } from 'use-scroll-animate/components/svelte';\n * import { onMount } from 'svelte';\n * onMount(() => defineUsa(['click', 'ui']));\n * let on = false;\n * </script>\n * <usa-toggle use:usa={{ props: { checked: on }, on: { change: (e) => (on = e.detail.checked) } }}></usa-toggle>\n * ```\n * Plain `on:usa:change` does not compile in Svelte 3/4 (colon); use the action or `onusa:change` in Svelte 5.\n */\nimport { defineComponents, type ComponentCategory } from '../index';\nimport { bindUsa, type UsaBinding } from './bind';\n\nexport { bindUsa, usaEventName } from './bind';\nexport type { UsaBinding } from './bind';\n\n/** Svelte action: `use:usa={{ props, on }}`. */\nexport function usa(node: HTMLElement, binding: UsaBinding = {}): { update(b: UsaBinding): void; destroy(): void } {\n return bindUsa(node, binding);\n}\n\n/** Register the elements (all, or some categories) — call from `onMount` for SSR apps. */\nexport function defineUsa(categories?: ComponentCategory[]): void {\n if (typeof window !== 'undefined') defineComponents(categories);\n}\n"],"names":["bindUsa","defineComponents"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;AAgBG;AAOH;SACgB,GAAG,CAAC,IAAiB,EAAE,UAAsB,EAAE,EAAA;AAC7D,IAAA,OAAOA,YAAO,CAAC,IAAI,EAAE,OAAO,CAAC;AAC/B;AAEA;AACM,SAAU,SAAS,CAAC,UAAgC,EAAA;IACxD,IAAI,OAAO,MAAM,KAAK,WAAW;QAAEC,2BAAgB,CAAC,UAAU,CAAC;AACjE;;;;;;;"}
|
|
@@ -1285,9 +1285,9 @@ declare global {
|
|
|
1285
1285
|
*/
|
|
1286
1286
|
type TimelinePosition = number | string;
|
|
1287
1287
|
interface TimelineStepOptions {
|
|
1288
|
-
/** Duration in ms (
|
|
1289
|
-
duration?: number;
|
|
1290
|
-
/** CSS easing (
|
|
1288
|
+
/** Duration in ms or a motion token name (`'fast'`, `'slow'`…; 4.2). Default: timeline default, 600. */
|
|
1289
|
+
duration?: number | string;
|
|
1290
|
+
/** CSS easing or a motion token name (`'emphasized'`, `'spring'`…; 4.2). Default `cubic-bezier(0.22, 1, 0.36, 1)`. */
|
|
1291
1291
|
easing?: string;
|
|
1292
1292
|
/** Start position, see `TimelinePosition`. */
|
|
1293
1293
|
at?: TimelinePosition;
|
|
@@ -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
|
*/
|
|
@@ -1285,9 +1285,9 @@ declare global {
|
|
|
1285
1285
|
*/
|
|
1286
1286
|
type TimelinePosition = number | string;
|
|
1287
1287
|
interface TimelineStepOptions {
|
|
1288
|
-
/** Duration in ms (
|
|
1289
|
-
duration?: number;
|
|
1290
|
-
/** CSS easing (
|
|
1288
|
+
/** Duration in ms or a motion token name (`'fast'`, `'slow'`…; 4.2). Default: timeline default, 600. */
|
|
1289
|
+
duration?: number | string;
|
|
1290
|
+
/** CSS easing or a motion token name (`'emphasized'`, `'spring'`…; 4.2). Default `cubic-bezier(0.22, 1, 0.36, 1)`. */
|
|
1291
1291
|
easing?: string;
|
|
1292
1292
|
/** Start position, see `TimelinePosition`. */
|
|
1293
1293
|
at?: TimelinePosition;
|
|
@@ -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,24 @@ 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-LkGRmgES.js';
|
|
20
|
+
import './tokens.js';
|
|
20
21
|
import './gesture.js';
|
|
21
|
-
import '../chunks/core-
|
|
22
|
+
import '../chunks/core-eXX8rB_b.js';
|
|
22
23
|
import './svg.js';
|
|
23
24
|
import './webgl.js';
|
|
24
25
|
import './depth.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"svelte.js","sources":["../../src/components/frameworks/svelte.ts"],"sourcesContent":["/**\n * use-scroll-animate/components/svelte — Svelte integration (v3.8).\n * Svelte (3, 4, 5) renders `<usa-*>` tags natively; `use:usa` sets\n * **properties** and `usa:*` listeners in one place, and `defineUsa()`\n * registers the elements on the client only (safe in SvelteKit SSR).\n *\n * ```svelte\n * <script>\n * import { usa, defineUsa } from 'use-scroll-animate/components/svelte';\n * import { onMount } from 'svelte';\n * onMount(() => defineUsa(['click', 'ui']));\n * let on = false;\n * </script>\n * <usa-toggle use:usa={{ props: { checked: on }, on: { change: (e) => (on = e.detail.checked) } }}></usa-toggle>\n * ```\n * Plain `on:usa:change` does not compile in Svelte 3/4 (colon); use the action or `onusa:change` in Svelte 5.\n */\nimport { defineComponents, type ComponentCategory } from '../index';\nimport { bindUsa, type UsaBinding } from './bind';\n\nexport { bindUsa, usaEventName } from './bind';\nexport type { UsaBinding } from './bind';\n\n/** Svelte action: `use:usa={{ props, on }}`. */\nexport function usa(node: HTMLElement, binding: UsaBinding = {}): { update(b: UsaBinding): void; destroy(): void } {\n return bindUsa(node, binding);\n}\n\n/** Register the elements (all, or some categories) — call from `onMount` for SSR apps. */\nexport function defineUsa(categories?: ComponentCategory[]): void {\n if (typeof window !== 'undefined') defineComponents(categories);\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"svelte.js","sources":["../../src/components/frameworks/svelte.ts"],"sourcesContent":["/**\n * use-scroll-animate/components/svelte — Svelte integration (v3.8).\n * Svelte (3, 4, 5) renders `<usa-*>` tags natively; `use:usa` sets\n * **properties** and `usa:*` listeners in one place, and `defineUsa()`\n * registers the elements on the client only (safe in SvelteKit SSR).\n *\n * ```svelte\n * <script>\n * import { usa, defineUsa } from 'use-scroll-animate/components/svelte';\n * import { onMount } from 'svelte';\n * onMount(() => defineUsa(['click', 'ui']));\n * let on = false;\n * </script>\n * <usa-toggle use:usa={{ props: { checked: on }, on: { change: (e) => (on = e.detail.checked) } }}></usa-toggle>\n * ```\n * Plain `on:usa:change` does not compile in Svelte 3/4 (colon); use the action or `onusa:change` in Svelte 5.\n */\nimport { defineComponents, type ComponentCategory } from '../index';\nimport { bindUsa, type UsaBinding } from './bind';\n\nexport { bindUsa, usaEventName } from './bind';\nexport type { UsaBinding } from './bind';\n\n/** Svelte action: `use:usa={{ props, on }}`. */\nexport function usa(node: HTMLElement, binding: UsaBinding = {}): { update(b: UsaBinding): void; destroy(): void } {\n return bindUsa(node, binding);\n}\n\n/** Register the elements (all, or some categories) — call from `onMount` for SSR apps. */\nexport function defineUsa(categories?: ComponentCategory[]): void {\n if (typeof window !== 'undefined') defineComponents(categories);\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;AAgBG;AAOH;SACgB,GAAG,CAAC,IAAiB,EAAE,UAAsB,EAAE,EAAA;AAC7D,IAAA,OAAO,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC;AAC/B;AAEA;AACM,SAAU,SAAS,CAAC,UAAgC,EAAA;IACxD,IAAI,OAAO,MAAM,KAAK,WAAW;QAAE,gBAAgB,CAAC,UAAU,CAAC;AACjE;;;;"}
|
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,8 @@
|
|
|
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-BRIIoKeS.cjs');
|
|
5
|
+
require('./tokens.cjs');
|
|
5
6
|
|
|
6
7
|
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
8
|
|
|
@@ -44,7 +45,13 @@ function defineTimeline(tag = 'usa-timeline') {
|
|
|
44
45
|
return;
|
|
45
46
|
}
|
|
46
47
|
if (this.flag('scrub')) {
|
|
47
|
-
|
|
48
|
+
// 4.1: native ScrollTimeline / ViewTimeline when available; `smooth`
|
|
49
|
+
// (0–0.95) or `scrub="js"` opt into the JS engine, `scrub="scroll"`
|
|
50
|
+
// follows this element's own scroll position.
|
|
51
|
+
const v = this.str('scrub');
|
|
52
|
+
const stop = tl.scrub(this, { smooth: this.num('smooth', 0), engine: v === 'js' ? 'js' : 'auto', source: v === 'scroll' ? 'scroll' : 'view' });
|
|
53
|
+
this.toggleAttribute('data-native', stop.native);
|
|
54
|
+
this.onCleanup(stop);
|
|
48
55
|
return;
|
|
49
56
|
}
|
|
50
57
|
const trigger = this.str('trigger', 'view');
|
|
@@ -97,6 +104,7 @@ exports.configureComponents = base.configureComponents;
|
|
|
97
104
|
exports.prefersReducedMotion = base.prefersReducedMotion;
|
|
98
105
|
exports.TIMELINE_PRESETS = core.TIMELINE_PRESETS;
|
|
99
106
|
exports.resolvePosition = core.resolvePosition;
|
|
107
|
+
exports.supportsNativeScrub = core.supportsNativeScrub;
|
|
100
108
|
exports.timeline = core.timeline;
|
|
101
109
|
exports.defineTimeline = defineTimeline;
|
|
102
110
|
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;QAEA,KAAK,GAAA;YACH,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC;AACtC,YAAA,MAAM,EAAE,IAAI,IAAI,CAAC,GAAG,GAAGC,aAAQ,CAAC,EAAE,QAAQ,EAAE,EAAE,QAAQ,EAAE,IAAI,CAAC,GAAG,CAAC,UAAU,EAAE,GAAG,CAAC,EAAE,OAAO,EAAE,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;AACxH,YAAA,IAAI,CAAC,gBAAgB,CAAc,WAAW,CAAC,CAAC,OAAO,CAAC,CAAC,EAAE,EAAE,CAAC,KAAI;AAChE,gBAAA,IAAI,EAAE,CAAC,OAAO,CAAC,KAAK;oBAAE,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,CAAC;gBAChD,MAAM,IAAI,GAAG,EAAE,CAAC,OAAO,CAAC,EAAE,IAAI,MAAM;AACpC,gBAAA,EAAE,CAAC,EAAE,CAAC,EAAE,EAAEC,qBAAgB,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,MAAM,EAAE;oBAChD,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,EAAE,KAAK,CAAC,IAAI,OAAO,GAAG,CAAA,EAAA,EAAK,OAAO,EAAE,GAAG,SAAS,CAAC;oBAChE,QAAQ,EAAE,EAAE,CAAC,OAAO,CAAC,QAAQ,GAAG,MAAM,CAAC,EAAE,CAAC,OAAO,CAAC,QAAQ,CAAC,GAAG,SAAS;AACxE,iBAAA,CAAC;AACJ,YAAA,CAAC,CAAC;YACF,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC,MAAM,EAAE,CAAC;AACjC,YAAA,IAAI,IAAI,CAAC,OAAO,EAAE;AAChB,gBAAA,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC;gBACpB;YACF;AACA,YAAA,IAAI,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,EAAE;;;;gBAItB,MAAM,CAAC,GAAG,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC;gBAC3B,MAAM,IAAI,GAAG,EAAE,CAAC,KAAK,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC,QAAQ,EAAE,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,KAAK,IAAI,GAAG,IAAI,GAAG,MAAM,EAAE,MAAM,EAAE,CAAC,KAAK,QAAQ,GAAG,QAAQ,GAAG,MAAM,EAAE,CAAC;gBAC9I,IAAI,CAAC,eAAe,CAAC,aAAa,EAAE,IAAI,CAAC,MAAM,CAAC;AAChD,gBAAA,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;gBACpB;YACF;YACA,MAAM,OAAO,GAAG,IAAI,CAAC,GAAG,CAAC,SAAS,EAAE,MAAM,CAAC;AAC3C,YAAA,IAAI,OAAO,KAAK,OAAO,EAAE;;;AAGvB,gBAAA,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,QAAQ,CAAC;AACpB,gBAAA,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,OAAO,EAAE,MAAM,KAAK,IAAI,CAAC,IAAI,EAAE,CAAC;gBAClD,IAAI,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,EAAE,CAAC,CAAgB,KAAI;oBAChD,IAAI,CAAC,CAAC,MAAM,KAAK,IAAI,KAAK,CAAC,CAAC,GAAG,KAAK,OAAO,IAAI,CAAC,CAAC,GAAG,KAAK,GAAG,CAAC,EAAE;wBAC7D,CAAC,CAAC,cAAc,EAAE;AAClB,wBAAA,KAAK,IAAI,CAAC,IAAI,EAAE;oBAClB;AACF,gBAAA,CAAC,CAAC;AACF,gBAAA,IAAI,CAAC,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC;AAAE,oBAAA,IAAI,CAAC,QAAQ,GAAG,CAAC;gBACrD;YACF;AACA,YAAA,EAAE,CAAC,IAAI,CAAC,CAAC,CAAC;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;;;;;;;;;;;"}
|
|
@@ -53,9 +53,9 @@ interface UsaElement extends HTMLElement {
|
|
|
53
53
|
*/
|
|
54
54
|
type TimelinePosition = number | string;
|
|
55
55
|
interface TimelineStepOptions {
|
|
56
|
-
/** Duration in ms (
|
|
57
|
-
duration?: number;
|
|
58
|
-
/** CSS easing (
|
|
56
|
+
/** Duration in ms or a motion token name (`'fast'`, `'slow'`…; 4.2). Default: timeline default, 600. */
|
|
57
|
+
duration?: number | string;
|
|
58
|
+
/** CSS easing or a motion token name (`'emphasized'`, `'spring'`…; 4.2). Default `cubic-bezier(0.22, 1, 0.36, 1)`. */
|
|
59
59
|
easing?: string;
|
|
60
60
|
/** Start position, see `TimelinePosition`. */
|
|
61
61
|
at?: TimelinePosition;
|
|
@@ -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 };
|