use-scroll-animate 5.7.0 → 5.9.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 +28 -0
- package/bin/usa-codemod-6.mjs +146 -0
- package/dist/components/angular.d.cts +2 -1
- package/dist/components/angular.d.ts +2 -1
- package/dist/components/click.cjs +23 -4
- package/dist/components/click.cjs.map +1 -1
- package/dist/components/click.d.cts +12 -7
- package/dist/components/click.d.ts +12 -7
- package/dist/components/click.js +28 -9
- package/dist/components/click.js.map +1 -1
- package/dist/components/effects.cjs +669 -2
- package/dist/components/effects.cjs.map +1 -1
- package/dist/components/effects.d.cts +176 -2
- package/dist/components/effects.d.ts +176 -2
- package/dist/components/effects.js +653 -5
- package/dist/components/effects.js.map +1 -1
- package/dist/components/fx.cjs +2 -2
- package/dist/components/fx.cjs.map +1 -1
- package/dist/components/fx.js +2 -2
- package/dist/components/fx.js.map +1 -1
- package/dist/components/lite.cjs +35 -14
- package/dist/components/lite.cjs.map +1 -1
- package/dist/components/lite.js +35 -14
- package/dist/components/lite.js.map +1 -1
- package/dist/components/page.cjs +2 -0
- package/dist/components/page.cjs.map +1 -1
- package/dist/components/page.js +3 -1
- package/dist/components/page.js.map +1 -1
- package/dist/components/solid.d.cts +2 -1
- package/dist/components/solid.d.ts +2 -1
- package/dist/components/svelte.d.cts +2 -1
- package/dist/components/svelte.d.ts +2 -1
- package/dist/components/vue.d.cts +2 -1
- package/dist/components/vue.d.ts +2 -1
- package/dist/components.cjs +5 -5
- package/dist/components.d.cts +12 -7
- package/dist/components.d.ts +12 -7
- package/dist/components.js +2 -2
- package/dist/components.umd.js +2 -2
- package/dist/components.umd.js.map +1 -1
- package/docs/ROADMAP.md +2 -2
- package/docs/components.md +46 -0
- package/docs/deprecations.md +4 -0
- package/docs/upgrading-6.md +32 -0
- package/package.json +3 -2
|
@@ -306,6 +306,178 @@ interface UsaGestureFxElement extends UsaElement {
|
|
|
306
306
|
*/
|
|
307
307
|
declare function defineGestureFx(tag?: string): CustomElementConstructor | undefined;
|
|
308
308
|
|
|
309
|
+
/**
|
|
310
|
+
* 5.8 — micro-interaction library (23 effects, registered through
|
|
311
|
+
* `registerEffect()`). Each one does the small piece of UI work as well as the
|
|
312
|
+
* motion — toggling `aria-pressed`, swapping a label, bumping a count, copying
|
|
313
|
+
* to the clipboard — so the state change still happens under reduced motion;
|
|
314
|
+
* only the animation is dropped (`ctx.animate` returns `null` there).
|
|
315
|
+
*
|
|
316
|
+
* Click: `copy-success`, `toggle-morph`, `password-reveal`, `favorite-star`,
|
|
317
|
+
* `like-heart`, `bookmark-flip`, `download-progress`, `submit-loading`,
|
|
318
|
+
* `send-plane`, `add-to-cart`, `counter-bump`, `upvote`, `clap`,
|
|
319
|
+
* `emoji-react`, `refresh-spin`, `trash-shake`, `check-toggle`.
|
|
320
|
+
* Attention: `input-shake`, `error-flash`, `success-check`, `nudge-hint`,
|
|
321
|
+
* `focus-pulse`, `notify-badge`.
|
|
322
|
+
*/
|
|
323
|
+
|
|
324
|
+
/** Toggle `aria-pressed` (or set it) and return the new state. */
|
|
325
|
+
declare function togglePressed(el: HTMLElement, force?: boolean): boolean;
|
|
326
|
+
/** Swap `el`'s label for `ms` (polite live region), then restore it. */
|
|
327
|
+
declare function swapLabel(el: HTMLElement, text: string, ms: number): Promise<void>;
|
|
328
|
+
/** Add `delta` to the number in `[data-count]` (or `el`), keeping it in `data-count`. Returns the new value. */
|
|
329
|
+
declare function bumpCount(el: HTMLElement, delta: number, ctx?: EffectContext): number;
|
|
330
|
+
declare const MICRO_FX: EffectDefinition[];
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* use-scroll-animate/components/tokens — motion design tokens (4.2).
|
|
334
|
+
*
|
|
335
|
+
* One source of truth for durations, easings and springs: as CSS custom
|
|
336
|
+
* properties (`--usa-duration-fast`, `--usa-easing-emphasized`,
|
|
337
|
+
* `--usa-spring-bouncy-stiffness`…), as W3C Design Tokens JSON, and importable
|
|
338
|
+
* from Figma Tokens (Tokens Studio) or Style Dictionary exports.
|
|
339
|
+
*
|
|
340
|
+
* ```ts
|
|
341
|
+
* import { applyMotionTokens, importMotionTokens, motionToken } from 'use-scroll-animate/components/tokens';
|
|
342
|
+
* applyMotionTokens(importMotionTokens(await (await fetch('/tokens.json')).json()));
|
|
343
|
+
* el.animate(frames, { duration: motionToken('duration', 'slow'), easing: motionToken('easing', 'emphasized') });
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
interface SpringToken {
|
|
347
|
+
stiffness: number;
|
|
348
|
+
damping: number;
|
|
349
|
+
mass: number;
|
|
350
|
+
}
|
|
351
|
+
interface MotionTokens {
|
|
352
|
+
/** Durations in ms. */
|
|
353
|
+
duration: Record<string, number>;
|
|
354
|
+
/** CSS easing strings. */
|
|
355
|
+
easing: Record<string, string>;
|
|
356
|
+
/** Spring physics parameters. */
|
|
357
|
+
spring: Record<string, SpringToken>;
|
|
358
|
+
}
|
|
359
|
+
type DeepPartialTokens = {
|
|
360
|
+
[K in keyof MotionTokens]?: Partial<MotionTokens[K]>;
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* 5.8 — theme packs: `neon`, `paper`, `glass`, `retro`, `brutalist`.
|
|
365
|
+
*
|
|
366
|
+
* A theme pack is design tokens (`--usa-theme-*` custom properties), motion
|
|
367
|
+
* tokens (merged over the 3.x motion scale) and effect presets per role
|
|
368
|
+
* (`enter`, `hover`, `click`, `attention`, `background`). Five theme effects
|
|
369
|
+
* ship with them: `neon-flicker`, `paper-fold`, `glass-shine`,
|
|
370
|
+
* `retro-scanlines`, `brutal-shift`.
|
|
371
|
+
*
|
|
372
|
+
* - `applyTheme(name, root?)` — on `<html>` (default) it also makes the motion
|
|
373
|
+
* tokens active for `motionToken()`; on any other element the tokens are
|
|
374
|
+
* only written as variables there. Returns an undo.
|
|
375
|
+
* - `themePreset(name, role)`, `playThemeEffect(el, role)` (theme of the
|
|
376
|
+
* closest `[data-usa-theme]`).
|
|
377
|
+
* - `<usa-theme name="neon">` — scopes a theme to its subtree and binds the
|
|
378
|
+
* presets to children with `data-theme-fx="click | hover | enter | attention"`.
|
|
379
|
+
*/
|
|
380
|
+
|
|
381
|
+
declare const THEME_ROLES: readonly ["enter", "hover", "click", "attention", "background"];
|
|
382
|
+
type ThemeRole = (typeof THEME_ROLES)[number];
|
|
383
|
+
interface ThemePack {
|
|
384
|
+
name: string;
|
|
385
|
+
/** Design tokens, written as `--usa-theme-<key>`. */
|
|
386
|
+
vars: Record<'bg' | 'fg' | 'accent' | 'accent-2' | 'surface' | 'border' | 'radius' | 'shadow' | 'font', string>;
|
|
387
|
+
/** Motion tokens merged over the defaults. */
|
|
388
|
+
motion: DeepPartialTokens;
|
|
389
|
+
/** Effect preset per role. */
|
|
390
|
+
presets: Record<ThemeRole, {
|
|
391
|
+
effect: string;
|
|
392
|
+
options?: Record<string, unknown>;
|
|
393
|
+
}>;
|
|
394
|
+
}
|
|
395
|
+
declare const THEMES: Record<string, ThemePack>;
|
|
396
|
+
declare const THEME_NAMES: string[];
|
|
397
|
+
/** The CSS custom properties of a theme (design + motion tokens). */
|
|
398
|
+
declare function themeVars(t: string | ThemePack): Record<string, string>;
|
|
399
|
+
/** A theme as a CSS rule (`selector` default `[data-usa-theme=<name>]`) — for SSR / static CSS. */
|
|
400
|
+
declare function themeCss(t: string | ThemePack, selector?: string): string;
|
|
401
|
+
/** Apply a theme to `root` (default `<html>`). Returns an undo. */
|
|
402
|
+
declare function applyTheme(t: string | ThemePack, root?: HTMLElement): () => void;
|
|
403
|
+
/** The effect preset of a theme for a role. */
|
|
404
|
+
declare function themePreset(t: string | ThemePack, role: ThemeRole): {
|
|
405
|
+
effect: string;
|
|
406
|
+
options?: Record<string, unknown>;
|
|
407
|
+
};
|
|
408
|
+
/** Play the preset for `role` of the theme on the closest `[data-usa-theme]` (or `theme`). */
|
|
409
|
+
declare function playThemeEffect(el: HTMLElement, role: ThemeRole, theme?: string): Promise<void>;
|
|
410
|
+
declare const THEME_FX: EffectDefinition[];
|
|
411
|
+
interface UsaThemeElement extends UsaElement {
|
|
412
|
+
readonly theme: string;
|
|
413
|
+
}
|
|
414
|
+
/** `<usa-theme name="neon | paper | glass | retro | brutalist">` — a themed subtree. */
|
|
415
|
+
declare function defineTheme(tag?: string): CustomElementConstructor | undefined;
|
|
416
|
+
|
|
417
|
+
interface AnimationTrack {
|
|
418
|
+
/** Selector inside the player (`:scope` = the player). */
|
|
419
|
+
target?: string;
|
|
420
|
+
/** Start time in ms. */
|
|
421
|
+
start?: number;
|
|
422
|
+
duration?: number;
|
|
423
|
+
/** A timeline preset (`fade-up`, `scale`, `blur`…). */
|
|
424
|
+
preset?: string;
|
|
425
|
+
keyframes?: Keyframe[];
|
|
426
|
+
easing?: string;
|
|
427
|
+
/** A registered effect fired at `start` (instead of keyframes). */
|
|
428
|
+
effect?: string;
|
|
429
|
+
options?: Record<string, unknown>;
|
|
430
|
+
label?: string;
|
|
431
|
+
}
|
|
432
|
+
interface AnimationJSON {
|
|
433
|
+
format?: string;
|
|
434
|
+
version?: number;
|
|
435
|
+
name?: string;
|
|
436
|
+
loop?: boolean;
|
|
437
|
+
/** Total length; defaults to the end of the last track. */
|
|
438
|
+
duration?: number;
|
|
439
|
+
tracks: AnimationTrack[];
|
|
440
|
+
}
|
|
441
|
+
declare const ANIMATION_FORMAT = "use-scroll-animate/animation";
|
|
442
|
+
/** Validate / normalise an animation (object or JSON text). Throws on anything unusable. */
|
|
443
|
+
declare function normalizeAnimation(input: string | AnimationJSON | Record<string, any>): Required<Pick<AnimationJSON, 'tracks' | 'duration' | 'loop' | 'name'>>;
|
|
444
|
+
interface Player {
|
|
445
|
+
readonly duration: number;
|
|
446
|
+
readonly currentTime: number;
|
|
447
|
+
readonly playing: boolean;
|
|
448
|
+
play(): void;
|
|
449
|
+
pause(): void;
|
|
450
|
+
/** Jump to `ms` (effects between are not replayed). */
|
|
451
|
+
seek(ms: number): void;
|
|
452
|
+
/** Playback rate (default 1). */
|
|
453
|
+
rate: number;
|
|
454
|
+
/** Resolves each time the animation reaches its end (not when looping). */
|
|
455
|
+
readonly finished: Promise<void>;
|
|
456
|
+
destroy(): void;
|
|
457
|
+
}
|
|
458
|
+
/** Bind an animation to `root` and return its controller (paused at 0 unless `autoplay`). */
|
|
459
|
+
declare function createPlayer(root: HTMLElement, animation: string | AnimationJSON, o?: {
|
|
460
|
+
autoplay?: boolean;
|
|
461
|
+
loop?: boolean;
|
|
462
|
+
rate?: number;
|
|
463
|
+
onFinish?: () => void;
|
|
464
|
+
}): Player;
|
|
465
|
+
interface UsaPlayerElement extends UsaElement {
|
|
466
|
+
readonly player: Player | null;
|
|
467
|
+
/** Load an animation (object or JSON text) and restart. */
|
|
468
|
+
load(animation: string | AnimationJSON): void;
|
|
469
|
+
play(): void;
|
|
470
|
+
pause(): void;
|
|
471
|
+
seek(ms: number): void;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* `<usa-player src="hero.json" | <script type="application/json"> child
|
|
475
|
+
* trigger="load | view | scroll | click | manual" loop rate controls>`.
|
|
476
|
+
* Emits `usa-player-ready` and `usa-player-finish`; sets `data-error` when the
|
|
477
|
+
* animation cannot be loaded.
|
|
478
|
+
*/
|
|
479
|
+
declare function definePlayer(tag?: string): CustomElementConstructor | undefined;
|
|
480
|
+
|
|
309
481
|
/**
|
|
310
482
|
* 5.4 — `<usa-story template="…">` scroll-storytelling templates.
|
|
311
483
|
*
|
|
@@ -362,10 +534,12 @@ declare function registerGenerativeEffects(): void;
|
|
|
362
534
|
declare function registerAudioEffects(): void;
|
|
363
535
|
/** 5.7: cursor trails, magnetic dots, spotlight cursor. */
|
|
364
536
|
declare function registerCursorEffects(): void;
|
|
537
|
+
/** 5.8: micro-interactions + theme-pack effects. */
|
|
538
|
+
declare function registerMicroEffects(): void;
|
|
365
539
|
/** Define the 5.x elements of this entry (`<usa-story>`, …) under their default tags. */
|
|
366
540
|
declare function defineEffectElements(): void;
|
|
367
541
|
/** Register the built-ins and every pack (idempotent). */
|
|
368
542
|
declare function registerAllEffects(): void;
|
|
369
543
|
|
|
370
|
-
export { AUDIO_FX, CARD_FX, CLICK_FX, CURSOR_FX, EFFECT_PACKS, GENERATIVE_FX, GESTURES, PAGE_FX, PHYSICS_FX, STORY_TEMPLATES, angleDelta, bindBeat, bindGesture, bounceKeyframes, canvasBackground, createBeatDetector, defineAudio, defineEffectElements, defineGestureFx, defineStory, disableAudio, enableAudio, flingVelocity, formatCount, fxLayer, getAudio, hexRgb, noise2, onBeat, registerAllEffects, registerAudioEffects, registerCardClickEffects, registerCursorEffects, registerGenerativeEffects, registerPageEffects, registerPhysicsEffects, solveSpring, springKeyframes, storyProgress };
|
|
371
|
-
export type { AudioInput, AudioReactive, AudioSample, BeatOptions, GenFrame, GenerativeSpec, GestureDetail, GestureFxOptions, GestureName, SpringOptions, StoryTemplate, UsaAudioElement, UsaGestureFxElement, UsaStoryElement };
|
|
544
|
+
export { ANIMATION_FORMAT, AUDIO_FX, CARD_FX, CLICK_FX, CURSOR_FX, EFFECT_PACKS, GENERATIVE_FX, GESTURES, MICRO_FX, PAGE_FX, PHYSICS_FX, STORY_TEMPLATES, THEMES, THEME_FX, THEME_NAMES, THEME_ROLES, angleDelta, applyTheme, bindBeat, bindGesture, bounceKeyframes, bumpCount, canvasBackground, createBeatDetector, createPlayer, defineAudio, defineEffectElements, defineGestureFx, definePlayer, defineStory, defineTheme, disableAudio, enableAudio, flingVelocity, formatCount, fxLayer, getAudio, hexRgb, noise2, normalizeAnimation, onBeat, playThemeEffect, registerAllEffects, registerAudioEffects, registerCardClickEffects, registerCursorEffects, registerGenerativeEffects, registerMicroEffects, registerPageEffects, registerPhysicsEffects, solveSpring, springKeyframes, storyProgress, swapLabel, themeCss, themePreset, themeVars, togglePressed };
|
|
545
|
+
export type { AnimationJSON, AnimationTrack, AudioInput, AudioReactive, AudioSample, BeatOptions, GenFrame, GenerativeSpec, GestureDetail, GestureFxOptions, GestureName, Player, SpringOptions, StoryTemplate, ThemePack, ThemeRole, UsaAudioElement, UsaGestureFxElement, UsaPlayerElement, UsaStoryElement, UsaThemeElement };
|
|
@@ -306,6 +306,178 @@ interface UsaGestureFxElement extends UsaElement {
|
|
|
306
306
|
*/
|
|
307
307
|
declare function defineGestureFx(tag?: string): CustomElementConstructor | undefined;
|
|
308
308
|
|
|
309
|
+
/**
|
|
310
|
+
* 5.8 — micro-interaction library (23 effects, registered through
|
|
311
|
+
* `registerEffect()`). Each one does the small piece of UI work as well as the
|
|
312
|
+
* motion — toggling `aria-pressed`, swapping a label, bumping a count, copying
|
|
313
|
+
* to the clipboard — so the state change still happens under reduced motion;
|
|
314
|
+
* only the animation is dropped (`ctx.animate` returns `null` there).
|
|
315
|
+
*
|
|
316
|
+
* Click: `copy-success`, `toggle-morph`, `password-reveal`, `favorite-star`,
|
|
317
|
+
* `like-heart`, `bookmark-flip`, `download-progress`, `submit-loading`,
|
|
318
|
+
* `send-plane`, `add-to-cart`, `counter-bump`, `upvote`, `clap`,
|
|
319
|
+
* `emoji-react`, `refresh-spin`, `trash-shake`, `check-toggle`.
|
|
320
|
+
* Attention: `input-shake`, `error-flash`, `success-check`, `nudge-hint`,
|
|
321
|
+
* `focus-pulse`, `notify-badge`.
|
|
322
|
+
*/
|
|
323
|
+
|
|
324
|
+
/** Toggle `aria-pressed` (or set it) and return the new state. */
|
|
325
|
+
declare function togglePressed(el: HTMLElement, force?: boolean): boolean;
|
|
326
|
+
/** Swap `el`'s label for `ms` (polite live region), then restore it. */
|
|
327
|
+
declare function swapLabel(el: HTMLElement, text: string, ms: number): Promise<void>;
|
|
328
|
+
/** Add `delta` to the number in `[data-count]` (or `el`), keeping it in `data-count`. Returns the new value. */
|
|
329
|
+
declare function bumpCount(el: HTMLElement, delta: number, ctx?: EffectContext): number;
|
|
330
|
+
declare const MICRO_FX: EffectDefinition[];
|
|
331
|
+
|
|
332
|
+
/**
|
|
333
|
+
* use-scroll-animate/components/tokens — motion design tokens (4.2).
|
|
334
|
+
*
|
|
335
|
+
* One source of truth for durations, easings and springs: as CSS custom
|
|
336
|
+
* properties (`--usa-duration-fast`, `--usa-easing-emphasized`,
|
|
337
|
+
* `--usa-spring-bouncy-stiffness`…), as W3C Design Tokens JSON, and importable
|
|
338
|
+
* from Figma Tokens (Tokens Studio) or Style Dictionary exports.
|
|
339
|
+
*
|
|
340
|
+
* ```ts
|
|
341
|
+
* import { applyMotionTokens, importMotionTokens, motionToken } from 'use-scroll-animate/components/tokens';
|
|
342
|
+
* applyMotionTokens(importMotionTokens(await (await fetch('/tokens.json')).json()));
|
|
343
|
+
* el.animate(frames, { duration: motionToken('duration', 'slow'), easing: motionToken('easing', 'emphasized') });
|
|
344
|
+
* ```
|
|
345
|
+
*/
|
|
346
|
+
interface SpringToken {
|
|
347
|
+
stiffness: number;
|
|
348
|
+
damping: number;
|
|
349
|
+
mass: number;
|
|
350
|
+
}
|
|
351
|
+
interface MotionTokens {
|
|
352
|
+
/** Durations in ms. */
|
|
353
|
+
duration: Record<string, number>;
|
|
354
|
+
/** CSS easing strings. */
|
|
355
|
+
easing: Record<string, string>;
|
|
356
|
+
/** Spring physics parameters. */
|
|
357
|
+
spring: Record<string, SpringToken>;
|
|
358
|
+
}
|
|
359
|
+
type DeepPartialTokens = {
|
|
360
|
+
[K in keyof MotionTokens]?: Partial<MotionTokens[K]>;
|
|
361
|
+
};
|
|
362
|
+
|
|
363
|
+
/**
|
|
364
|
+
* 5.8 — theme packs: `neon`, `paper`, `glass`, `retro`, `brutalist`.
|
|
365
|
+
*
|
|
366
|
+
* A theme pack is design tokens (`--usa-theme-*` custom properties), motion
|
|
367
|
+
* tokens (merged over the 3.x motion scale) and effect presets per role
|
|
368
|
+
* (`enter`, `hover`, `click`, `attention`, `background`). Five theme effects
|
|
369
|
+
* ship with them: `neon-flicker`, `paper-fold`, `glass-shine`,
|
|
370
|
+
* `retro-scanlines`, `brutal-shift`.
|
|
371
|
+
*
|
|
372
|
+
* - `applyTheme(name, root?)` — on `<html>` (default) it also makes the motion
|
|
373
|
+
* tokens active for `motionToken()`; on any other element the tokens are
|
|
374
|
+
* only written as variables there. Returns an undo.
|
|
375
|
+
* - `themePreset(name, role)`, `playThemeEffect(el, role)` (theme of the
|
|
376
|
+
* closest `[data-usa-theme]`).
|
|
377
|
+
* - `<usa-theme name="neon">` — scopes a theme to its subtree and binds the
|
|
378
|
+
* presets to children with `data-theme-fx="click | hover | enter | attention"`.
|
|
379
|
+
*/
|
|
380
|
+
|
|
381
|
+
declare const THEME_ROLES: readonly ["enter", "hover", "click", "attention", "background"];
|
|
382
|
+
type ThemeRole = (typeof THEME_ROLES)[number];
|
|
383
|
+
interface ThemePack {
|
|
384
|
+
name: string;
|
|
385
|
+
/** Design tokens, written as `--usa-theme-<key>`. */
|
|
386
|
+
vars: Record<'bg' | 'fg' | 'accent' | 'accent-2' | 'surface' | 'border' | 'radius' | 'shadow' | 'font', string>;
|
|
387
|
+
/** Motion tokens merged over the defaults. */
|
|
388
|
+
motion: DeepPartialTokens;
|
|
389
|
+
/** Effect preset per role. */
|
|
390
|
+
presets: Record<ThemeRole, {
|
|
391
|
+
effect: string;
|
|
392
|
+
options?: Record<string, unknown>;
|
|
393
|
+
}>;
|
|
394
|
+
}
|
|
395
|
+
declare const THEMES: Record<string, ThemePack>;
|
|
396
|
+
declare const THEME_NAMES: string[];
|
|
397
|
+
/** The CSS custom properties of a theme (design + motion tokens). */
|
|
398
|
+
declare function themeVars(t: string | ThemePack): Record<string, string>;
|
|
399
|
+
/** A theme as a CSS rule (`selector` default `[data-usa-theme=<name>]`) — for SSR / static CSS. */
|
|
400
|
+
declare function themeCss(t: string | ThemePack, selector?: string): string;
|
|
401
|
+
/** Apply a theme to `root` (default `<html>`). Returns an undo. */
|
|
402
|
+
declare function applyTheme(t: string | ThemePack, root?: HTMLElement): () => void;
|
|
403
|
+
/** The effect preset of a theme for a role. */
|
|
404
|
+
declare function themePreset(t: string | ThemePack, role: ThemeRole): {
|
|
405
|
+
effect: string;
|
|
406
|
+
options?: Record<string, unknown>;
|
|
407
|
+
};
|
|
408
|
+
/** Play the preset for `role` of the theme on the closest `[data-usa-theme]` (or `theme`). */
|
|
409
|
+
declare function playThemeEffect(el: HTMLElement, role: ThemeRole, theme?: string): Promise<void>;
|
|
410
|
+
declare const THEME_FX: EffectDefinition[];
|
|
411
|
+
interface UsaThemeElement extends UsaElement {
|
|
412
|
+
readonly theme: string;
|
|
413
|
+
}
|
|
414
|
+
/** `<usa-theme name="neon | paper | glass | retro | brutalist">` — a themed subtree. */
|
|
415
|
+
declare function defineTheme(tag?: string): CustomElementConstructor | undefined;
|
|
416
|
+
|
|
417
|
+
interface AnimationTrack {
|
|
418
|
+
/** Selector inside the player (`:scope` = the player). */
|
|
419
|
+
target?: string;
|
|
420
|
+
/** Start time in ms. */
|
|
421
|
+
start?: number;
|
|
422
|
+
duration?: number;
|
|
423
|
+
/** A timeline preset (`fade-up`, `scale`, `blur`…). */
|
|
424
|
+
preset?: string;
|
|
425
|
+
keyframes?: Keyframe[];
|
|
426
|
+
easing?: string;
|
|
427
|
+
/** A registered effect fired at `start` (instead of keyframes). */
|
|
428
|
+
effect?: string;
|
|
429
|
+
options?: Record<string, unknown>;
|
|
430
|
+
label?: string;
|
|
431
|
+
}
|
|
432
|
+
interface AnimationJSON {
|
|
433
|
+
format?: string;
|
|
434
|
+
version?: number;
|
|
435
|
+
name?: string;
|
|
436
|
+
loop?: boolean;
|
|
437
|
+
/** Total length; defaults to the end of the last track. */
|
|
438
|
+
duration?: number;
|
|
439
|
+
tracks: AnimationTrack[];
|
|
440
|
+
}
|
|
441
|
+
declare const ANIMATION_FORMAT = "use-scroll-animate/animation";
|
|
442
|
+
/** Validate / normalise an animation (object or JSON text). Throws on anything unusable. */
|
|
443
|
+
declare function normalizeAnimation(input: string | AnimationJSON | Record<string, any>): Required<Pick<AnimationJSON, 'tracks' | 'duration' | 'loop' | 'name'>>;
|
|
444
|
+
interface Player {
|
|
445
|
+
readonly duration: number;
|
|
446
|
+
readonly currentTime: number;
|
|
447
|
+
readonly playing: boolean;
|
|
448
|
+
play(): void;
|
|
449
|
+
pause(): void;
|
|
450
|
+
/** Jump to `ms` (effects between are not replayed). */
|
|
451
|
+
seek(ms: number): void;
|
|
452
|
+
/** Playback rate (default 1). */
|
|
453
|
+
rate: number;
|
|
454
|
+
/** Resolves each time the animation reaches its end (not when looping). */
|
|
455
|
+
readonly finished: Promise<void>;
|
|
456
|
+
destroy(): void;
|
|
457
|
+
}
|
|
458
|
+
/** Bind an animation to `root` and return its controller (paused at 0 unless `autoplay`). */
|
|
459
|
+
declare function createPlayer(root: HTMLElement, animation: string | AnimationJSON, o?: {
|
|
460
|
+
autoplay?: boolean;
|
|
461
|
+
loop?: boolean;
|
|
462
|
+
rate?: number;
|
|
463
|
+
onFinish?: () => void;
|
|
464
|
+
}): Player;
|
|
465
|
+
interface UsaPlayerElement extends UsaElement {
|
|
466
|
+
readonly player: Player | null;
|
|
467
|
+
/** Load an animation (object or JSON text) and restart. */
|
|
468
|
+
load(animation: string | AnimationJSON): void;
|
|
469
|
+
play(): void;
|
|
470
|
+
pause(): void;
|
|
471
|
+
seek(ms: number): void;
|
|
472
|
+
}
|
|
473
|
+
/**
|
|
474
|
+
* `<usa-player src="hero.json" | <script type="application/json"> child
|
|
475
|
+
* trigger="load | view | scroll | click | manual" loop rate controls>`.
|
|
476
|
+
* Emits `usa-player-ready` and `usa-player-finish`; sets `data-error` when the
|
|
477
|
+
* animation cannot be loaded.
|
|
478
|
+
*/
|
|
479
|
+
declare function definePlayer(tag?: string): CustomElementConstructor | undefined;
|
|
480
|
+
|
|
309
481
|
/**
|
|
310
482
|
* 5.4 — `<usa-story template="…">` scroll-storytelling templates.
|
|
311
483
|
*
|
|
@@ -362,10 +534,12 @@ declare function registerGenerativeEffects(): void;
|
|
|
362
534
|
declare function registerAudioEffects(): void;
|
|
363
535
|
/** 5.7: cursor trails, magnetic dots, spotlight cursor. */
|
|
364
536
|
declare function registerCursorEffects(): void;
|
|
537
|
+
/** 5.8: micro-interactions + theme-pack effects. */
|
|
538
|
+
declare function registerMicroEffects(): void;
|
|
365
539
|
/** Define the 5.x elements of this entry (`<usa-story>`, …) under their default tags. */
|
|
366
540
|
declare function defineEffectElements(): void;
|
|
367
541
|
/** Register the built-ins and every pack (idempotent). */
|
|
368
542
|
declare function registerAllEffects(): void;
|
|
369
543
|
|
|
370
|
-
export { AUDIO_FX, CARD_FX, CLICK_FX, CURSOR_FX, EFFECT_PACKS, GENERATIVE_FX, GESTURES, PAGE_FX, PHYSICS_FX, STORY_TEMPLATES, angleDelta, bindBeat, bindGesture, bounceKeyframes, canvasBackground, createBeatDetector, defineAudio, defineEffectElements, defineGestureFx, defineStory, disableAudio, enableAudio, flingVelocity, formatCount, fxLayer, getAudio, hexRgb, noise2, onBeat, registerAllEffects, registerAudioEffects, registerCardClickEffects, registerCursorEffects, registerGenerativeEffects, registerPageEffects, registerPhysicsEffects, solveSpring, springKeyframes, storyProgress };
|
|
371
|
-
export type { AudioInput, AudioReactive, AudioSample, BeatOptions, GenFrame, GenerativeSpec, GestureDetail, GestureFxOptions, GestureName, SpringOptions, StoryTemplate, UsaAudioElement, UsaGestureFxElement, UsaStoryElement };
|
|
544
|
+
export { ANIMATION_FORMAT, AUDIO_FX, CARD_FX, CLICK_FX, CURSOR_FX, EFFECT_PACKS, GENERATIVE_FX, GESTURES, MICRO_FX, PAGE_FX, PHYSICS_FX, STORY_TEMPLATES, THEMES, THEME_FX, THEME_NAMES, THEME_ROLES, angleDelta, applyTheme, bindBeat, bindGesture, bounceKeyframes, bumpCount, canvasBackground, createBeatDetector, createPlayer, defineAudio, defineEffectElements, defineGestureFx, definePlayer, defineStory, defineTheme, disableAudio, enableAudio, flingVelocity, formatCount, fxLayer, getAudio, hexRgb, noise2, normalizeAnimation, onBeat, playThemeEffect, registerAllEffects, registerAudioEffects, registerCardClickEffects, registerCursorEffects, registerGenerativeEffects, registerMicroEffects, registerPageEffects, registerPhysicsEffects, solveSpring, springKeyframes, storyProgress, swapLabel, themeCss, themePreset, themeVars, togglePressed };
|
|
545
|
+
export type { AnimationJSON, AnimationTrack, AudioInput, AudioReactive, AudioSample, BeatOptions, GenFrame, GenerativeSpec, GestureDetail, GestureFxOptions, GestureName, Player, SpringOptions, StoryTemplate, ThemePack, ThemeRole, UsaAudioElement, UsaGestureFxElement, UsaPlayerElement, UsaStoryElement, UsaThemeElement };
|