use-scroll-animate 3.0.0 → 3.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 +20 -0
- package/README.md +2 -0
- package/README_ja.md +2 -0
- package/README_zh.md +2 -0
- package/dist/chunks/{base-Co98Z2iM.js → base-Cu-86Z31.js} +2 -2
- package/dist/chunks/{base-Co98Z2iM.js.map → base-Cu-86Z31.js.map} +1 -1
- package/dist/chunks/{index-tags-BEM98giN.cjs → index-tags-DCTX4F9b.cjs} +3 -1
- package/dist/chunks/{index-tags-BEM98giN.cjs.map → index-tags-DCTX4F9b.cjs.map} +1 -1
- package/dist/chunks/{index-tags-f37txHmb.js → index-tags-DZ-gjMZc.js} +3 -1
- package/dist/chunks/{index-tags-f37txHmb.js.map → index-tags-DZ-gjMZc.js.map} +1 -1
- package/dist/chunks/{spring-YNUpez2g.js → spring-BV-cpTHC.js} +2 -2
- package/dist/chunks/{spring-YNUpez2g.js.map → spring-BV-cpTHC.js.map} +1 -1
- package/dist/chunks/{variants-Dp_5lJ_J.js → variants-BQ3gCb5L.js} +2 -2
- package/dist/chunks/{variants-Dp_5lJ_J.js.map → variants-BQ3gCb5L.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/feedback.js +2 -2
- package/dist/components/gesture.cjs +387 -0
- package/dist/components/gesture.cjs.map +1 -0
- package/dist/components/gesture.css +3 -0
- package/dist/components/gesture.d.cts +169 -0
- package/dist/components/gesture.d.ts +169 -0
- package/dist/components/gesture.js +379 -0
- package/dist/components/gesture.js.map +1 -0
- package/dist/components/interaction.js +2 -2
- package/dist/components/jsx.d.cts +2 -0
- package/dist/components/jsx.d.ts +2 -0
- package/dist/components/lazy.cjs +3 -1
- package/dist/components/lazy.cjs.map +1 -1
- package/dist/components/lazy.d.cts +2 -0
- package/dist/components/lazy.d.ts +2 -0
- package/dist/components/lazy.js +3 -1
- package/dist/components/lazy.js.map +1 -1
- package/dist/components/page.js +3 -3
- package/dist/components/physics.js +4 -4
- package/dist/components/react.cjs +1 -1
- package/dist/components/react.js +1 -1
- package/dist/components/reveal.js +2 -2
- package/dist/components/text.js +2 -2
- package/dist/components/timeline.cjs +303 -0
- package/dist/components/timeline.cjs.map +1 -0
- package/dist/components/timeline.css +3 -0
- package/dist/components/timeline.d.cts +164 -0
- package/dist/components/timeline.d.ts +164 -0
- package/dist/components/timeline.js +296 -0
- package/dist/components/timeline.js.map +1 -0
- package/dist/components/transitions.js +2 -2
- package/dist/components/ui.js +5 -5
- package/dist/components/vue.cjs +3 -1
- package/dist/components/vue.cjs.map +1 -1
- package/dist/components/vue.d.cts +135 -0
- package/dist/components/vue.d.ts +135 -0
- package/dist/components/vue.js +6 -4
- package/dist/components/vue.js.map +1 -1
- package/dist/components.cjs +16 -1
- package/dist/components.cjs.map +1 -1
- package/dist/components.css +2 -0
- package/dist/components.d.cts +243 -2
- package/dist/components.d.ts +243 -2
- package/dist/components.js +13 -7
- package/dist/components.js.map +1 -1
- package/dist/components.umd.js +2 -2
- package/dist/components.umd.js.map +1 -1
- package/docs/components.md +17 -0
- package/package.json +24 -2
package/dist/components.d.cts
CHANGED
|
@@ -1774,6 +1774,245 @@ declare global {
|
|
|
1774
1774
|
}
|
|
1775
1775
|
}
|
|
1776
1776
|
|
|
1777
|
+
/**
|
|
1778
|
+
* Where a step starts on a timeline:
|
|
1779
|
+
* - a number: absolute time in ms
|
|
1780
|
+
* - `'>'` (default): when the previous step ends · `'<'`: when it starts
|
|
1781
|
+
* - `'+=200'` / `'-=200'`: after / overlapping the previous end
|
|
1782
|
+
* - `'<+=100'`: 100ms after the previous step's start
|
|
1783
|
+
* - `'intro'` / `'intro+=150'`: at (or relative to) a label
|
|
1784
|
+
*/
|
|
1785
|
+
type TimelinePosition = number | string;
|
|
1786
|
+
interface TimelineStepOptions {
|
|
1787
|
+
/** Duration in ms (default: timeline default, 600). */
|
|
1788
|
+
duration?: number;
|
|
1789
|
+
/** CSS easing (default `cubic-bezier(0.22, 1, 0.36, 1)`). */
|
|
1790
|
+
easing?: string;
|
|
1791
|
+
/** Start position, see `TimelinePosition`. */
|
|
1792
|
+
at?: TimelinePosition;
|
|
1793
|
+
/** ms between targets when the selector matches several elements. */
|
|
1794
|
+
stagger?: number;
|
|
1795
|
+
}
|
|
1796
|
+
interface TimelineOptions {
|
|
1797
|
+
/** Defaults for every step. */
|
|
1798
|
+
defaults?: Pick<TimelineStepOptions, 'duration' | 'easing' | 'stagger'>;
|
|
1799
|
+
/** Playback rate (1 = normal). */
|
|
1800
|
+
speed?: number;
|
|
1801
|
+
/** Called after `play()` reaches the end (or the start when reversed). */
|
|
1802
|
+
onComplete?: () => void;
|
|
1803
|
+
/** Called on every frame with progress 0–1. */
|
|
1804
|
+
onUpdate?: (progress: number) => void;
|
|
1805
|
+
}
|
|
1806
|
+
interface ScrubOptions {
|
|
1807
|
+
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts. */
|
|
1808
|
+
offset?: number;
|
|
1809
|
+
/** Smoothing 0–1 (0 = immediate, default 0). */
|
|
1810
|
+
smooth?: number;
|
|
1811
|
+
}
|
|
1812
|
+
interface Timeline {
|
|
1813
|
+
/** Total length in ms. */
|
|
1814
|
+
readonly duration: number;
|
|
1815
|
+
/** Label positions in ms. */
|
|
1816
|
+
readonly labels: Readonly<Record<string, number>>;
|
|
1817
|
+
/** Current playhead in ms. */
|
|
1818
|
+
readonly time: number;
|
|
1819
|
+
/** Add a step: animate `target` with keyframes or a preset name (`fade-up`, `scale`…). */
|
|
1820
|
+
to(target: string | Element | Element[] | NodeList, frames: Keyframe[] | string, options?: TimelineStepOptions): Timeline;
|
|
1821
|
+
/** Name a position (default: the current end). */
|
|
1822
|
+
label(name: string, at?: TimelinePosition): Timeline;
|
|
1823
|
+
/** Run `fn` when the playhead passes `at`. */
|
|
1824
|
+
call(fn: () => void, at?: TimelinePosition): Timeline;
|
|
1825
|
+
/** Play forwards from the playhead (from 0 when at the end). Resolves at the end. */
|
|
1826
|
+
play(from?: TimelinePosition): Promise<void>;
|
|
1827
|
+
/** Play backwards to 0. */
|
|
1828
|
+
reverse(): Promise<void>;
|
|
1829
|
+
pause(): Timeline;
|
|
1830
|
+
/** Jump to a time (ms) or label. */
|
|
1831
|
+
seek(to: TimelinePosition): Timeline;
|
|
1832
|
+
/** Get or set progress 0–1. */
|
|
1833
|
+
progress(p?: number): number;
|
|
1834
|
+
/** Tie progress to the scroll position of `source` (it moves through the viewport). Returns a stop function. */
|
|
1835
|
+
scrub(source: Element, options?: ScrubOptions): () => void;
|
|
1836
|
+
/** Stop and drop every animation (elements keep their last frame). */
|
|
1837
|
+
cancel(): void;
|
|
1838
|
+
}
|
|
1839
|
+
/** Keyframe presets usable by name in `to()` and `data-tl`. */
|
|
1840
|
+
declare const TIMELINE_PRESETS: Record<string, Keyframe[]>;
|
|
1841
|
+
/** Resolve a position against the previous step and labels (pure). */
|
|
1842
|
+
declare function resolvePosition(pos: TimelinePosition | undefined, end: number, prevStart: number, labels?: Record<string, number>): number;
|
|
1843
|
+
/**
|
|
1844
|
+
* Choreograph animations on one clock: chain, overlap, label, seek, reverse and
|
|
1845
|
+
* scrub them with scroll. Built on WAAPI (paused animations driven by one
|
|
1846
|
+
* playhead); without WAAPI or under reduced motion it jumps to the end state.
|
|
1847
|
+
*
|
|
1848
|
+
* @example
|
|
1849
|
+
* const tl = timeline({ defaults: { duration: 500 } })
|
|
1850
|
+
* .to('.title', 'fade-up')
|
|
1851
|
+
* .label('cards')
|
|
1852
|
+
* .to('.card', 'scale', { stagger: 80, at: '-=200' })
|
|
1853
|
+
* .to('.cta', [{ opacity: 0 }, { opacity: 1 }], { at: 'cards+=400' });
|
|
1854
|
+
* tl.play(); // or tl.scrub(document.querySelector('.hero'))
|
|
1855
|
+
*/
|
|
1856
|
+
declare function timeline(options?: TimelineOptions): Timeline;
|
|
1857
|
+
|
|
1858
|
+
/**
|
|
1859
|
+
* `<usa-timeline>` — declarative choreography. Every descendant with
|
|
1860
|
+
* `data-tl="<preset>"` becomes a step, in document order; `data-at`
|
|
1861
|
+
* (`'-=200'`, `'<'`, `'label+=100'`, ms), `data-duration` and `data-label`
|
|
1862
|
+
* fine-tune it.
|
|
1863
|
+
*
|
|
1864
|
+
* Attributes: `trigger` (`view` default · `click` · `manual`), `scrub`
|
|
1865
|
+
* (progress follows scroll instead of playing), `overlap` (ms each step
|
|
1866
|
+
* overlaps the previous, default 0), `duration` (600), `stagger` (ms),
|
|
1867
|
+
* `repeat` (replay every time it enters the viewport). Methods: `play()`,
|
|
1868
|
+
* `reverse()`, `seek(t)`; property `timeline`. Event `usa:complete`.
|
|
1869
|
+
* Reduced motion: steps appear in their final state.
|
|
1870
|
+
*/
|
|
1871
|
+
interface UsaTimelineElement extends UsaElement {
|
|
1872
|
+
readonly timeline: Timeline | null;
|
|
1873
|
+
play(): Promise<void>;
|
|
1874
|
+
reverse(): Promise<void>;
|
|
1875
|
+
seek(to: number | string): void;
|
|
1876
|
+
}
|
|
1877
|
+
declare function defineTimeline(tag?: string): CustomElementConstructor | undefined;
|
|
1878
|
+
|
|
1879
|
+
/**
|
|
1880
|
+
* use-scroll-animate/components/timeline — choreography (v3.1).
|
|
1881
|
+
* `timeline()` chains, overlaps, labels, seeks, reverses and scroll-scrubs
|
|
1882
|
+
* WAAPI animations on one playhead; `<usa-timeline>` builds one from
|
|
1883
|
+
* `data-tl` children.
|
|
1884
|
+
*/
|
|
1885
|
+
|
|
1886
|
+
/** Register every component of this category under its default tag. */
|
|
1887
|
+
declare function defineTimelineComponents(): void;
|
|
1888
|
+
declare global {
|
|
1889
|
+
interface HTMLElementTagNameMap {
|
|
1890
|
+
'usa-timeline': UsaTimelineElement;
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
interface PanState {
|
|
1895
|
+
/** Offset from the gesture start (px). */
|
|
1896
|
+
dx: number;
|
|
1897
|
+
dy: number;
|
|
1898
|
+
/** Velocity (px/s). */
|
|
1899
|
+
vx: number;
|
|
1900
|
+
vy: number;
|
|
1901
|
+
first: boolean;
|
|
1902
|
+
last: boolean;
|
|
1903
|
+
event: Event;
|
|
1904
|
+
}
|
|
1905
|
+
type SwipeDirection = 'left' | 'right' | 'up' | 'down';
|
|
1906
|
+
interface SwipeState {
|
|
1907
|
+
direction: SwipeDirection;
|
|
1908
|
+
velocity: number;
|
|
1909
|
+
dx: number;
|
|
1910
|
+
dy: number;
|
|
1911
|
+
}
|
|
1912
|
+
interface PinchState {
|
|
1913
|
+
scale: number; /** Midpoint of the two pointers (client px). */
|
|
1914
|
+
x: number;
|
|
1915
|
+
y: number;
|
|
1916
|
+
first: boolean;
|
|
1917
|
+
last: boolean;
|
|
1918
|
+
}
|
|
1919
|
+
interface PressState {
|
|
1920
|
+
x: number;
|
|
1921
|
+
y: number;
|
|
1922
|
+
}
|
|
1923
|
+
interface GestureHandlers {
|
|
1924
|
+
onPan?: (s: PanState) => void;
|
|
1925
|
+
onSwipe?: (s: SwipeState) => void;
|
|
1926
|
+
onPinch?: (s: PinchState) => void;
|
|
1927
|
+
onLongPress?: (s: PressState) => void;
|
|
1928
|
+
onTap?: (s: PressState) => void;
|
|
1929
|
+
onDoubleTap?: (s: PressState) => void;
|
|
1930
|
+
}
|
|
1931
|
+
interface GestureOptions {
|
|
1932
|
+
/** Restrict panning to an axis. */
|
|
1933
|
+
axis?: 'x' | 'y';
|
|
1934
|
+
/** Movement (px) before a pan starts (default 4). */
|
|
1935
|
+
threshold?: number;
|
|
1936
|
+
/** Minimum distance (px, default 40) and speed (px/s, default 300) for a swipe. */
|
|
1937
|
+
swipeDistance?: number;
|
|
1938
|
+
swipeVelocity?: number;
|
|
1939
|
+
/** Long-press delay (ms, default 500). */
|
|
1940
|
+
longPress?: number;
|
|
1941
|
+
/** Ctrl/⌘ + wheel (trackpad pinch) counts as pinch (default true). */
|
|
1942
|
+
wheelPinch?: boolean;
|
|
1943
|
+
}
|
|
1944
|
+
/** The swipe a pointer release represents, or `null` (pure). */
|
|
1945
|
+
declare function swipeDirection(dx: number, dy: number, vx: number, vy: number, o?: {
|
|
1946
|
+
distance?: number;
|
|
1947
|
+
velocity?: number;
|
|
1948
|
+
axis?: 'x' | 'y';
|
|
1949
|
+
}): SwipeState | null;
|
|
1950
|
+
/** Scale between two pointer distances, clamped to [min, max] (pure). */
|
|
1951
|
+
declare function pinchScale(startDistance: number, distance: number, base?: number, min?: number, max?: number): number;
|
|
1952
|
+
/**
|
|
1953
|
+
* One recognizer for pan, swipe, pinch (two pointers or Ctrl + wheel),
|
|
1954
|
+
* long-press, tap and double-tap, with velocities ready to hand to a spring
|
|
1955
|
+
* (`createSpring().set(target, velocity)`). Works with mouse, touch and pen
|
|
1956
|
+
* through Pointer Events. Returns a cleanup function.
|
|
1957
|
+
*
|
|
1958
|
+
* @example
|
|
1959
|
+
* const x = createSpring({ onUpdate: (v) => (card.style.translate = `${v}px`) });
|
|
1960
|
+
* gesture(card, {
|
|
1961
|
+
* onPan: ({ dx, last, vx }) => (last ? x.set(0, vx) : x.jump(dx)),
|
|
1962
|
+
* onSwipe: ({ direction }) => dismiss(direction),
|
|
1963
|
+
* }, { axis: 'x' });
|
|
1964
|
+
*/
|
|
1965
|
+
declare function gesture(el: HTMLElement, h: GestureHandlers, o?: GestureOptions): () => void;
|
|
1966
|
+
|
|
1967
|
+
/**
|
|
1968
|
+
* `<usa-swipeable>` — swipe-to-dismiss / swipe actions. The content follows
|
|
1969
|
+
* the finger (rubber-banded past `distance`), flies out on a swipe or a drag
|
|
1970
|
+
* past `distance`, otherwise springs home with the release velocity.
|
|
1971
|
+
*
|
|
1972
|
+
* Attributes: `axis` (`x` default · `y`), `distance` (px, 120), `preset`
|
|
1973
|
+
* (spring), `dismiss` (remove the element after flying out), `disabled`.
|
|
1974
|
+
* Keyboard: Delete/Backspace dismisses, ←/→ swipe. Events `usa:swipe`
|
|
1975
|
+
* (`{ direction }`, cancelable), `usa:dismiss`. Methods `swipe(dir)`, `reset()`.
|
|
1976
|
+
* Reduced motion: no follow / fly-out animation, events still fire.
|
|
1977
|
+
*/
|
|
1978
|
+
interface UsaSwipeableElement extends UsaElement {
|
|
1979
|
+
swipe(direction: SwipeDirection): void;
|
|
1980
|
+
reset(): void;
|
|
1981
|
+
readonly offset: number;
|
|
1982
|
+
}
|
|
1983
|
+
declare function defineSwipeable(tag?: string): CustomElementConstructor | undefined;
|
|
1984
|
+
|
|
1985
|
+
/**
|
|
1986
|
+
* `<usa-pinch-zoom>` — pinch (two fingers or Ctrl/⌘ + wheel / trackpad
|
|
1987
|
+
* pinch) to zoom its content, pan while zoomed, double-tap to toggle zoom;
|
|
1988
|
+
* scale and position spring back inside the bounds on release.
|
|
1989
|
+
*
|
|
1990
|
+
* Attributes: `min` (1), `max` (4), `double-tap` (zoom level, 2), `preset`.
|
|
1991
|
+
* Keyboard: `+` / `-` / `0`. Property `scale`, method `zoomTo(scale)`.
|
|
1992
|
+
* Event `usa:zoom` (`{ scale }`). Reduced motion: zoom changes instantly.
|
|
1993
|
+
*/
|
|
1994
|
+
interface UsaPinchZoomElement extends UsaElement {
|
|
1995
|
+
readonly scale: number;
|
|
1996
|
+
zoomTo(scale: number): void;
|
|
1997
|
+
}
|
|
1998
|
+
declare function definePinchZoom(tag?: string): CustomElementConstructor | undefined;
|
|
1999
|
+
|
|
2000
|
+
/**
|
|
2001
|
+
* use-scroll-animate/components/gesture — unified gestures (v3.2).
|
|
2002
|
+
* `gesture()` recognises pan, swipe, pinch, long-press, tap and double-tap
|
|
2003
|
+
* with release velocities for springs; `<usa-swipeable>` (swipe-to-dismiss)
|
|
2004
|
+
* and `<usa-pinch-zoom>` are built on it.
|
|
2005
|
+
*/
|
|
2006
|
+
|
|
2007
|
+
/** Register every component of this category under its default tag. */
|
|
2008
|
+
declare function defineGestureComponents(): void;
|
|
2009
|
+
declare global {
|
|
2010
|
+
interface HTMLElementTagNameMap {
|
|
2011
|
+
'usa-swipeable': UsaSwipeableElement;
|
|
2012
|
+
'usa-pinch-zoom': UsaPinchZoomElement;
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
|
|
1777
2016
|
/** The component categories and their default tags. */
|
|
1778
2017
|
declare const COMPONENT_CATEGORIES: {
|
|
1779
2018
|
readonly reveal: readonly ["usa-reveal", "usa-stagger", "usa-scroll-progress", "usa-scrolly"];
|
|
@@ -1787,6 +2026,8 @@ declare const COMPONENT_CATEGORIES: {
|
|
|
1787
2026
|
readonly click: readonly ["usa-click", "usa-button", "usa-icon-morph", "usa-like", "usa-hold", "usa-double-tap", "usa-checkbox"];
|
|
1788
2027
|
readonly ui: readonly ["usa-tabs", "usa-drawer", "usa-bottom-sheet", "usa-pull-refresh", "usa-fab", "usa-navbar", "usa-slider", "usa-rating", "usa-tooltip", "usa-popover", "usa-badge", "usa-avatar-stack"];
|
|
1789
2028
|
readonly page: readonly ["usa-cursor", "usa-fullpage", "usa-loading-bar", "usa-back-to-top", "usa-ambient", "usa-splash", "usa-auto-skeleton", "usa-motion-switch"];
|
|
2029
|
+
readonly timeline: readonly ["usa-timeline"];
|
|
2030
|
+
readonly gesture: readonly ["usa-swipeable", "usa-pinch-zoom"];
|
|
1790
2031
|
};
|
|
1791
2032
|
type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
|
|
1792
2033
|
|
|
@@ -1796,5 +2037,5 @@ type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
|
|
|
1796
2037
|
*/
|
|
1797
2038
|
declare function defineComponents(categories?: ComponentCategory[]): void;
|
|
1798
2039
|
|
|
1799
|
-
export { AMBIENT_EFFECTS, BUTTON_DEFORMS, CARD_EFFECTS, CLICK_EFFECTS, COMPONENT_CATEGORIES, CURSOR_MODES, MORPH_ICONS, MOTION_SCALE, PAGE_EFFECTS, REVEAL_EFFECTS, SPINNER_VARIANTS, SPRING_EFFECTS, SPRING_PRESETS, VARIANTS, adoptVariants, burst, confetti, configureComponents, connectedAnimation, createSpring, defineAccordion, defineAcrylic, defineAmbient, defineAurora, defineAutoSkeleton, defineAvatarStack, defineBackToTop, defineBackgroundComponents, defineBadge, defineBlobs, defineBottomSheet, defineButton, defineCard, defineCardComponents, defineCardStack, defineCarousel3d, defineCheck, defineCheckbox, defineClick, defineClickComponents, defineComponents, defineCounter, defineCursor, defineDialog, defineDotNetwork, defineDoubleTap, defineDraggable, defineDrawer, defineFab, defineFeedbackComponents, defineFlipList, defineFullpage, defineGlitch, defineGradientText, defineGrain, defineGridGlow, defineHandwriting, defineHold, defineIconMorph, defineInteractionComponents, defineLike, defineLoadingBar, defineMagnetic, defineMarquee, defineMotionSwitch, defineNavbar, defineOverscroll, definePageComponents, defineParticles, definePhysicsComponents, definePopover, definePress, defineProgress, definePullRefresh, defineRating, defineReveal, defineRevealComponents, defineRipple, defineScramble, defineScrollHighlight, defineScrollProgress, defineScrolly, defineShimmerText, defineSkeleton, defineSlider, defineSpinner, defineSplash, defineSplitText, defineSpotlight, defineSpring, defineStagger, defineStickyStack, defineTabs, defineTextComponents, defineTextRotate, defineTilt, defineToaster, defineToggle, defineTooltip, defineTransitionComponents, defineTypewriter, defineUiComponents, defineViewSwitch, defineWaterRipple, defineWaveText, easeOutExpo, enableMpaTransitions, flip, fluentPreset, getMotionIntensity, haptic, linearEasing, loadingBar, morphPath, pageTransition, prefersReducedMotion, projectInertia, readScrollProgress, resolveSpring, restoreMotionIntensity, revealKeyframes, rubberBand, scrambleFrame, scrollToTarget, setMotionIntensity, setVariant, shake, smoothScroll, snapTo, spring, springEasing, springEffectKeyframes, springSamples, stepSpring, supportsLinearEasing, supportsViewTransitions, themeTransition, toast, viewTransition };
|
|
1800
|
-
export type { AmbientEffect, BurstOptions, ButtonDeform, ButtonShape, ButtonState, CardEffect, ClickEffect, ComponentCategory, ComponentsConfig, ConfettiOptions, ConnectedOptions, CursorMode, DialogVariant, FlipOptions, FluentPresetOptions, MotionIntensity, PageEffect, PageTransitionOptions, Placement, RevealEffect, SmoothScrollOptions, SpinnerVariant, SpringConfig, SpringEffect, SpringInput, SpringPreset, SpringValue, SpringValueOptions, ToastHandle, ToastOptions, ToastType, UsaAccordionElement, UsaAcrylicElement, UsaAmbientElement, UsaAuroraElement, UsaAutoSkeletonElement, UsaAvatarStackElement, UsaBackToTopElement, UsaBadgeElement, UsaBlobsElement, UsaBottomSheetElement, UsaButtonElement, UsaCardElement, UsaCardStackElement, UsaCarousel3dElement, UsaCheckElement, UsaCheckboxElement, UsaClickElement, UsaCounterElement, UsaCursorElement, UsaDialogElement, UsaDotNetworkElement, UsaDoubleTapElement, UsaDraggableElement, UsaDrawerElement, UsaElement, UsaFabElement, UsaFlipListElement, UsaFullpageElement, UsaGlitchElement, UsaGradientTextElement, UsaGrainElement, UsaGridGlowElement, UsaHandwritingElement, UsaHoldElement, UsaIconMorphElement, UsaLikeElement, UsaLoadingBarElement, UsaMagneticElement, UsaMarqueeElement, UsaMotionSwitchElement, UsaNavbarElement, UsaOverscrollElement, UsaParticlesElement, UsaPopoverElement, UsaPressElement, UsaProgressElement, UsaPullRefreshElement, UsaRatingElement, UsaRevealElement, UsaRippleElement, UsaScrambleElement, UsaScrollHighlightElement, UsaScrollProgressElement, UsaScrollyElement, UsaShimmerTextElement, UsaSkeletonElement, UsaSliderElement, UsaSpinnerElement, UsaSplashElement, UsaSplitTextElement, UsaSpotlightElement, UsaSpringElement, UsaStaggerElement, UsaStickyStackElement, UsaTabsElement, UsaTextRotateElement, UsaTiltElement, UsaToasterElement, UsaToggleElement, UsaTooltipElement, UsaTypewriterElement, UsaViewSwitchElement, UsaWaterRippleElement, UsaWaveTextElement, Variant, ViewTransitionOptions };
|
|
2040
|
+
export { AMBIENT_EFFECTS, BUTTON_DEFORMS, CARD_EFFECTS, CLICK_EFFECTS, COMPONENT_CATEGORIES, CURSOR_MODES, MORPH_ICONS, MOTION_SCALE, PAGE_EFFECTS, REVEAL_EFFECTS, SPINNER_VARIANTS, SPRING_EFFECTS, SPRING_PRESETS, TIMELINE_PRESETS, VARIANTS, adoptVariants, burst, confetti, configureComponents, connectedAnimation, createSpring, defineAccordion, defineAcrylic, defineAmbient, defineAurora, defineAutoSkeleton, defineAvatarStack, defineBackToTop, defineBackgroundComponents, defineBadge, defineBlobs, defineBottomSheet, defineButton, defineCard, defineCardComponents, defineCardStack, defineCarousel3d, defineCheck, defineCheckbox, defineClick, defineClickComponents, defineComponents, defineCounter, defineCursor, defineDialog, defineDotNetwork, defineDoubleTap, defineDraggable, defineDrawer, defineFab, defineFeedbackComponents, defineFlipList, defineFullpage, defineGestureComponents, defineGlitch, defineGradientText, defineGrain, defineGridGlow, defineHandwriting, defineHold, defineIconMorph, defineInteractionComponents, defineLike, defineLoadingBar, defineMagnetic, defineMarquee, defineMotionSwitch, defineNavbar, defineOverscroll, definePageComponents, defineParticles, definePhysicsComponents, definePinchZoom, definePopover, definePress, defineProgress, definePullRefresh, defineRating, defineReveal, defineRevealComponents, defineRipple, defineScramble, defineScrollHighlight, defineScrollProgress, defineScrolly, defineShimmerText, defineSkeleton, defineSlider, defineSpinner, defineSplash, defineSplitText, defineSpotlight, defineSpring, defineStagger, defineStickyStack, defineSwipeable, defineTabs, defineTextComponents, defineTextRotate, defineTilt, defineTimeline, defineTimelineComponents, defineToaster, defineToggle, defineTooltip, defineTransitionComponents, defineTypewriter, defineUiComponents, defineViewSwitch, defineWaterRipple, defineWaveText, easeOutExpo, enableMpaTransitions, flip, fluentPreset, gesture, getMotionIntensity, haptic, linearEasing, loadingBar, morphPath, pageTransition, pinchScale, prefersReducedMotion, projectInertia, readScrollProgress, resolvePosition, resolveSpring, restoreMotionIntensity, revealKeyframes, rubberBand, scrambleFrame, scrollToTarget, setMotionIntensity, setVariant, shake, smoothScroll, snapTo, spring, springEasing, springEffectKeyframes, springSamples, stepSpring, supportsLinearEasing, supportsViewTransitions, swipeDirection, themeTransition, timeline, toast, viewTransition };
|
|
2041
|
+
export type { AmbientEffect, BurstOptions, ButtonDeform, ButtonShape, ButtonState, CardEffect, ClickEffect, ComponentCategory, ComponentsConfig, ConfettiOptions, ConnectedOptions, CursorMode, DialogVariant, FlipOptions, FluentPresetOptions, GestureHandlers, GestureOptions, MotionIntensity, PageEffect, PageTransitionOptions, PanState, PinchState, Placement, PressState, RevealEffect, ScrubOptions, SmoothScrollOptions, SpinnerVariant, SpringConfig, SpringEffect, SpringInput, SpringPreset, SpringValue, SpringValueOptions, SwipeDirection, SwipeState, Timeline, TimelineOptions, TimelinePosition, TimelineStepOptions, ToastHandle, ToastOptions, ToastType, UsaAccordionElement, UsaAcrylicElement, UsaAmbientElement, UsaAuroraElement, UsaAutoSkeletonElement, UsaAvatarStackElement, UsaBackToTopElement, UsaBadgeElement, UsaBlobsElement, UsaBottomSheetElement, UsaButtonElement, UsaCardElement, UsaCardStackElement, UsaCarousel3dElement, UsaCheckElement, UsaCheckboxElement, UsaClickElement, UsaCounterElement, UsaCursorElement, UsaDialogElement, UsaDotNetworkElement, UsaDoubleTapElement, UsaDraggableElement, UsaDrawerElement, UsaElement, UsaFabElement, UsaFlipListElement, UsaFullpageElement, UsaGlitchElement, UsaGradientTextElement, UsaGrainElement, UsaGridGlowElement, UsaHandwritingElement, UsaHoldElement, UsaIconMorphElement, UsaLikeElement, UsaLoadingBarElement, UsaMagneticElement, UsaMarqueeElement, UsaMotionSwitchElement, UsaNavbarElement, UsaOverscrollElement, UsaParticlesElement, UsaPinchZoomElement, UsaPopoverElement, UsaPressElement, UsaProgressElement, UsaPullRefreshElement, UsaRatingElement, UsaRevealElement, UsaRippleElement, UsaScrambleElement, UsaScrollHighlightElement, UsaScrollProgressElement, UsaScrollyElement, UsaShimmerTextElement, UsaSkeletonElement, UsaSliderElement, UsaSpinnerElement, UsaSplashElement, UsaSplitTextElement, UsaSpotlightElement, UsaSpringElement, UsaStaggerElement, UsaStickyStackElement, UsaSwipeableElement, UsaTabsElement, UsaTextRotateElement, UsaTiltElement, UsaTimelineElement, UsaToasterElement, UsaToggleElement, UsaTooltipElement, UsaTypewriterElement, UsaViewSwitchElement, UsaWaterRippleElement, UsaWaveTextElement, Variant, ViewTransitionOptions };
|
package/dist/components.d.ts
CHANGED
|
@@ -1774,6 +1774,245 @@ declare global {
|
|
|
1774
1774
|
}
|
|
1775
1775
|
}
|
|
1776
1776
|
|
|
1777
|
+
/**
|
|
1778
|
+
* Where a step starts on a timeline:
|
|
1779
|
+
* - a number: absolute time in ms
|
|
1780
|
+
* - `'>'` (default): when the previous step ends · `'<'`: when it starts
|
|
1781
|
+
* - `'+=200'` / `'-=200'`: after / overlapping the previous end
|
|
1782
|
+
* - `'<+=100'`: 100ms after the previous step's start
|
|
1783
|
+
* - `'intro'` / `'intro+=150'`: at (or relative to) a label
|
|
1784
|
+
*/
|
|
1785
|
+
type TimelinePosition = number | string;
|
|
1786
|
+
interface TimelineStepOptions {
|
|
1787
|
+
/** Duration in ms (default: timeline default, 600). */
|
|
1788
|
+
duration?: number;
|
|
1789
|
+
/** CSS easing (default `cubic-bezier(0.22, 1, 0.36, 1)`). */
|
|
1790
|
+
easing?: string;
|
|
1791
|
+
/** Start position, see `TimelinePosition`. */
|
|
1792
|
+
at?: TimelinePosition;
|
|
1793
|
+
/** ms between targets when the selector matches several elements. */
|
|
1794
|
+
stagger?: number;
|
|
1795
|
+
}
|
|
1796
|
+
interface TimelineOptions {
|
|
1797
|
+
/** Defaults for every step. */
|
|
1798
|
+
defaults?: Pick<TimelineStepOptions, 'duration' | 'easing' | 'stagger'>;
|
|
1799
|
+
/** Playback rate (1 = normal). */
|
|
1800
|
+
speed?: number;
|
|
1801
|
+
/** Called after `play()` reaches the end (or the start when reversed). */
|
|
1802
|
+
onComplete?: () => void;
|
|
1803
|
+
/** Called on every frame with progress 0–1. */
|
|
1804
|
+
onUpdate?: (progress: number) => void;
|
|
1805
|
+
}
|
|
1806
|
+
interface ScrubOptions {
|
|
1807
|
+
/** Scroll offset (px) before the source's top reaches the viewport bottom where progress starts. */
|
|
1808
|
+
offset?: number;
|
|
1809
|
+
/** Smoothing 0–1 (0 = immediate, default 0). */
|
|
1810
|
+
smooth?: number;
|
|
1811
|
+
}
|
|
1812
|
+
interface Timeline {
|
|
1813
|
+
/** Total length in ms. */
|
|
1814
|
+
readonly duration: number;
|
|
1815
|
+
/** Label positions in ms. */
|
|
1816
|
+
readonly labels: Readonly<Record<string, number>>;
|
|
1817
|
+
/** Current playhead in ms. */
|
|
1818
|
+
readonly time: number;
|
|
1819
|
+
/** Add a step: animate `target` with keyframes or a preset name (`fade-up`, `scale`…). */
|
|
1820
|
+
to(target: string | Element | Element[] | NodeList, frames: Keyframe[] | string, options?: TimelineStepOptions): Timeline;
|
|
1821
|
+
/** Name a position (default: the current end). */
|
|
1822
|
+
label(name: string, at?: TimelinePosition): Timeline;
|
|
1823
|
+
/** Run `fn` when the playhead passes `at`. */
|
|
1824
|
+
call(fn: () => void, at?: TimelinePosition): Timeline;
|
|
1825
|
+
/** Play forwards from the playhead (from 0 when at the end). Resolves at the end. */
|
|
1826
|
+
play(from?: TimelinePosition): Promise<void>;
|
|
1827
|
+
/** Play backwards to 0. */
|
|
1828
|
+
reverse(): Promise<void>;
|
|
1829
|
+
pause(): Timeline;
|
|
1830
|
+
/** Jump to a time (ms) or label. */
|
|
1831
|
+
seek(to: TimelinePosition): Timeline;
|
|
1832
|
+
/** Get or set progress 0–1. */
|
|
1833
|
+
progress(p?: number): number;
|
|
1834
|
+
/** Tie progress to the scroll position of `source` (it moves through the viewport). Returns a stop function. */
|
|
1835
|
+
scrub(source: Element, options?: ScrubOptions): () => void;
|
|
1836
|
+
/** Stop and drop every animation (elements keep their last frame). */
|
|
1837
|
+
cancel(): void;
|
|
1838
|
+
}
|
|
1839
|
+
/** Keyframe presets usable by name in `to()` and `data-tl`. */
|
|
1840
|
+
declare const TIMELINE_PRESETS: Record<string, Keyframe[]>;
|
|
1841
|
+
/** Resolve a position against the previous step and labels (pure). */
|
|
1842
|
+
declare function resolvePosition(pos: TimelinePosition | undefined, end: number, prevStart: number, labels?: Record<string, number>): number;
|
|
1843
|
+
/**
|
|
1844
|
+
* Choreograph animations on one clock: chain, overlap, label, seek, reverse and
|
|
1845
|
+
* scrub them with scroll. Built on WAAPI (paused animations driven by one
|
|
1846
|
+
* playhead); without WAAPI or under reduced motion it jumps to the end state.
|
|
1847
|
+
*
|
|
1848
|
+
* @example
|
|
1849
|
+
* const tl = timeline({ defaults: { duration: 500 } })
|
|
1850
|
+
* .to('.title', 'fade-up')
|
|
1851
|
+
* .label('cards')
|
|
1852
|
+
* .to('.card', 'scale', { stagger: 80, at: '-=200' })
|
|
1853
|
+
* .to('.cta', [{ opacity: 0 }, { opacity: 1 }], { at: 'cards+=400' });
|
|
1854
|
+
* tl.play(); // or tl.scrub(document.querySelector('.hero'))
|
|
1855
|
+
*/
|
|
1856
|
+
declare function timeline(options?: TimelineOptions): Timeline;
|
|
1857
|
+
|
|
1858
|
+
/**
|
|
1859
|
+
* `<usa-timeline>` — declarative choreography. Every descendant with
|
|
1860
|
+
* `data-tl="<preset>"` becomes a step, in document order; `data-at`
|
|
1861
|
+
* (`'-=200'`, `'<'`, `'label+=100'`, ms), `data-duration` and `data-label`
|
|
1862
|
+
* fine-tune it.
|
|
1863
|
+
*
|
|
1864
|
+
* Attributes: `trigger` (`view` default · `click` · `manual`), `scrub`
|
|
1865
|
+
* (progress follows scroll instead of playing), `overlap` (ms each step
|
|
1866
|
+
* overlaps the previous, default 0), `duration` (600), `stagger` (ms),
|
|
1867
|
+
* `repeat` (replay every time it enters the viewport). Methods: `play()`,
|
|
1868
|
+
* `reverse()`, `seek(t)`; property `timeline`. Event `usa:complete`.
|
|
1869
|
+
* Reduced motion: steps appear in their final state.
|
|
1870
|
+
*/
|
|
1871
|
+
interface UsaTimelineElement extends UsaElement {
|
|
1872
|
+
readonly timeline: Timeline | null;
|
|
1873
|
+
play(): Promise<void>;
|
|
1874
|
+
reverse(): Promise<void>;
|
|
1875
|
+
seek(to: number | string): void;
|
|
1876
|
+
}
|
|
1877
|
+
declare function defineTimeline(tag?: string): CustomElementConstructor | undefined;
|
|
1878
|
+
|
|
1879
|
+
/**
|
|
1880
|
+
* use-scroll-animate/components/timeline — choreography (v3.1).
|
|
1881
|
+
* `timeline()` chains, overlaps, labels, seeks, reverses and scroll-scrubs
|
|
1882
|
+
* WAAPI animations on one playhead; `<usa-timeline>` builds one from
|
|
1883
|
+
* `data-tl` children.
|
|
1884
|
+
*/
|
|
1885
|
+
|
|
1886
|
+
/** Register every component of this category under its default tag. */
|
|
1887
|
+
declare function defineTimelineComponents(): void;
|
|
1888
|
+
declare global {
|
|
1889
|
+
interface HTMLElementTagNameMap {
|
|
1890
|
+
'usa-timeline': UsaTimelineElement;
|
|
1891
|
+
}
|
|
1892
|
+
}
|
|
1893
|
+
|
|
1894
|
+
interface PanState {
|
|
1895
|
+
/** Offset from the gesture start (px). */
|
|
1896
|
+
dx: number;
|
|
1897
|
+
dy: number;
|
|
1898
|
+
/** Velocity (px/s). */
|
|
1899
|
+
vx: number;
|
|
1900
|
+
vy: number;
|
|
1901
|
+
first: boolean;
|
|
1902
|
+
last: boolean;
|
|
1903
|
+
event: Event;
|
|
1904
|
+
}
|
|
1905
|
+
type SwipeDirection = 'left' | 'right' | 'up' | 'down';
|
|
1906
|
+
interface SwipeState {
|
|
1907
|
+
direction: SwipeDirection;
|
|
1908
|
+
velocity: number;
|
|
1909
|
+
dx: number;
|
|
1910
|
+
dy: number;
|
|
1911
|
+
}
|
|
1912
|
+
interface PinchState {
|
|
1913
|
+
scale: number; /** Midpoint of the two pointers (client px). */
|
|
1914
|
+
x: number;
|
|
1915
|
+
y: number;
|
|
1916
|
+
first: boolean;
|
|
1917
|
+
last: boolean;
|
|
1918
|
+
}
|
|
1919
|
+
interface PressState {
|
|
1920
|
+
x: number;
|
|
1921
|
+
y: number;
|
|
1922
|
+
}
|
|
1923
|
+
interface GestureHandlers {
|
|
1924
|
+
onPan?: (s: PanState) => void;
|
|
1925
|
+
onSwipe?: (s: SwipeState) => void;
|
|
1926
|
+
onPinch?: (s: PinchState) => void;
|
|
1927
|
+
onLongPress?: (s: PressState) => void;
|
|
1928
|
+
onTap?: (s: PressState) => void;
|
|
1929
|
+
onDoubleTap?: (s: PressState) => void;
|
|
1930
|
+
}
|
|
1931
|
+
interface GestureOptions {
|
|
1932
|
+
/** Restrict panning to an axis. */
|
|
1933
|
+
axis?: 'x' | 'y';
|
|
1934
|
+
/** Movement (px) before a pan starts (default 4). */
|
|
1935
|
+
threshold?: number;
|
|
1936
|
+
/** Minimum distance (px, default 40) and speed (px/s, default 300) for a swipe. */
|
|
1937
|
+
swipeDistance?: number;
|
|
1938
|
+
swipeVelocity?: number;
|
|
1939
|
+
/** Long-press delay (ms, default 500). */
|
|
1940
|
+
longPress?: number;
|
|
1941
|
+
/** Ctrl/⌘ + wheel (trackpad pinch) counts as pinch (default true). */
|
|
1942
|
+
wheelPinch?: boolean;
|
|
1943
|
+
}
|
|
1944
|
+
/** The swipe a pointer release represents, or `null` (pure). */
|
|
1945
|
+
declare function swipeDirection(dx: number, dy: number, vx: number, vy: number, o?: {
|
|
1946
|
+
distance?: number;
|
|
1947
|
+
velocity?: number;
|
|
1948
|
+
axis?: 'x' | 'y';
|
|
1949
|
+
}): SwipeState | null;
|
|
1950
|
+
/** Scale between two pointer distances, clamped to [min, max] (pure). */
|
|
1951
|
+
declare function pinchScale(startDistance: number, distance: number, base?: number, min?: number, max?: number): number;
|
|
1952
|
+
/**
|
|
1953
|
+
* One recognizer for pan, swipe, pinch (two pointers or Ctrl + wheel),
|
|
1954
|
+
* long-press, tap and double-tap, with velocities ready to hand to a spring
|
|
1955
|
+
* (`createSpring().set(target, velocity)`). Works with mouse, touch and pen
|
|
1956
|
+
* through Pointer Events. Returns a cleanup function.
|
|
1957
|
+
*
|
|
1958
|
+
* @example
|
|
1959
|
+
* const x = createSpring({ onUpdate: (v) => (card.style.translate = `${v}px`) });
|
|
1960
|
+
* gesture(card, {
|
|
1961
|
+
* onPan: ({ dx, last, vx }) => (last ? x.set(0, vx) : x.jump(dx)),
|
|
1962
|
+
* onSwipe: ({ direction }) => dismiss(direction),
|
|
1963
|
+
* }, { axis: 'x' });
|
|
1964
|
+
*/
|
|
1965
|
+
declare function gesture(el: HTMLElement, h: GestureHandlers, o?: GestureOptions): () => void;
|
|
1966
|
+
|
|
1967
|
+
/**
|
|
1968
|
+
* `<usa-swipeable>` — swipe-to-dismiss / swipe actions. The content follows
|
|
1969
|
+
* the finger (rubber-banded past `distance`), flies out on a swipe or a drag
|
|
1970
|
+
* past `distance`, otherwise springs home with the release velocity.
|
|
1971
|
+
*
|
|
1972
|
+
* Attributes: `axis` (`x` default · `y`), `distance` (px, 120), `preset`
|
|
1973
|
+
* (spring), `dismiss` (remove the element after flying out), `disabled`.
|
|
1974
|
+
* Keyboard: Delete/Backspace dismisses, ←/→ swipe. Events `usa:swipe`
|
|
1975
|
+
* (`{ direction }`, cancelable), `usa:dismiss`. Methods `swipe(dir)`, `reset()`.
|
|
1976
|
+
* Reduced motion: no follow / fly-out animation, events still fire.
|
|
1977
|
+
*/
|
|
1978
|
+
interface UsaSwipeableElement extends UsaElement {
|
|
1979
|
+
swipe(direction: SwipeDirection): void;
|
|
1980
|
+
reset(): void;
|
|
1981
|
+
readonly offset: number;
|
|
1982
|
+
}
|
|
1983
|
+
declare function defineSwipeable(tag?: string): CustomElementConstructor | undefined;
|
|
1984
|
+
|
|
1985
|
+
/**
|
|
1986
|
+
* `<usa-pinch-zoom>` — pinch (two fingers or Ctrl/⌘ + wheel / trackpad
|
|
1987
|
+
* pinch) to zoom its content, pan while zoomed, double-tap to toggle zoom;
|
|
1988
|
+
* scale and position spring back inside the bounds on release.
|
|
1989
|
+
*
|
|
1990
|
+
* Attributes: `min` (1), `max` (4), `double-tap` (zoom level, 2), `preset`.
|
|
1991
|
+
* Keyboard: `+` / `-` / `0`. Property `scale`, method `zoomTo(scale)`.
|
|
1992
|
+
* Event `usa:zoom` (`{ scale }`). Reduced motion: zoom changes instantly.
|
|
1993
|
+
*/
|
|
1994
|
+
interface UsaPinchZoomElement extends UsaElement {
|
|
1995
|
+
readonly scale: number;
|
|
1996
|
+
zoomTo(scale: number): void;
|
|
1997
|
+
}
|
|
1998
|
+
declare function definePinchZoom(tag?: string): CustomElementConstructor | undefined;
|
|
1999
|
+
|
|
2000
|
+
/**
|
|
2001
|
+
* use-scroll-animate/components/gesture — unified gestures (v3.2).
|
|
2002
|
+
* `gesture()` recognises pan, swipe, pinch, long-press, tap and double-tap
|
|
2003
|
+
* with release velocities for springs; `<usa-swipeable>` (swipe-to-dismiss)
|
|
2004
|
+
* and `<usa-pinch-zoom>` are built on it.
|
|
2005
|
+
*/
|
|
2006
|
+
|
|
2007
|
+
/** Register every component of this category under its default tag. */
|
|
2008
|
+
declare function defineGestureComponents(): void;
|
|
2009
|
+
declare global {
|
|
2010
|
+
interface HTMLElementTagNameMap {
|
|
2011
|
+
'usa-swipeable': UsaSwipeableElement;
|
|
2012
|
+
'usa-pinch-zoom': UsaPinchZoomElement;
|
|
2013
|
+
}
|
|
2014
|
+
}
|
|
2015
|
+
|
|
1777
2016
|
/** The component categories and their default tags. */
|
|
1778
2017
|
declare const COMPONENT_CATEGORIES: {
|
|
1779
2018
|
readonly reveal: readonly ["usa-reveal", "usa-stagger", "usa-scroll-progress", "usa-scrolly"];
|
|
@@ -1787,6 +2026,8 @@ declare const COMPONENT_CATEGORIES: {
|
|
|
1787
2026
|
readonly click: readonly ["usa-click", "usa-button", "usa-icon-morph", "usa-like", "usa-hold", "usa-double-tap", "usa-checkbox"];
|
|
1788
2027
|
readonly ui: readonly ["usa-tabs", "usa-drawer", "usa-bottom-sheet", "usa-pull-refresh", "usa-fab", "usa-navbar", "usa-slider", "usa-rating", "usa-tooltip", "usa-popover", "usa-badge", "usa-avatar-stack"];
|
|
1789
2028
|
readonly page: readonly ["usa-cursor", "usa-fullpage", "usa-loading-bar", "usa-back-to-top", "usa-ambient", "usa-splash", "usa-auto-skeleton", "usa-motion-switch"];
|
|
2029
|
+
readonly timeline: readonly ["usa-timeline"];
|
|
2030
|
+
readonly gesture: readonly ["usa-swipeable", "usa-pinch-zoom"];
|
|
1790
2031
|
};
|
|
1791
2032
|
type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
|
|
1792
2033
|
|
|
@@ -1796,5 +2037,5 @@ type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
|
|
|
1796
2037
|
*/
|
|
1797
2038
|
declare function defineComponents(categories?: ComponentCategory[]): void;
|
|
1798
2039
|
|
|
1799
|
-
export { AMBIENT_EFFECTS, BUTTON_DEFORMS, CARD_EFFECTS, CLICK_EFFECTS, COMPONENT_CATEGORIES, CURSOR_MODES, MORPH_ICONS, MOTION_SCALE, PAGE_EFFECTS, REVEAL_EFFECTS, SPINNER_VARIANTS, SPRING_EFFECTS, SPRING_PRESETS, VARIANTS, adoptVariants, burst, confetti, configureComponents, connectedAnimation, createSpring, defineAccordion, defineAcrylic, defineAmbient, defineAurora, defineAutoSkeleton, defineAvatarStack, defineBackToTop, defineBackgroundComponents, defineBadge, defineBlobs, defineBottomSheet, defineButton, defineCard, defineCardComponents, defineCardStack, defineCarousel3d, defineCheck, defineCheckbox, defineClick, defineClickComponents, defineComponents, defineCounter, defineCursor, defineDialog, defineDotNetwork, defineDoubleTap, defineDraggable, defineDrawer, defineFab, defineFeedbackComponents, defineFlipList, defineFullpage, defineGlitch, defineGradientText, defineGrain, defineGridGlow, defineHandwriting, defineHold, defineIconMorph, defineInteractionComponents, defineLike, defineLoadingBar, defineMagnetic, defineMarquee, defineMotionSwitch, defineNavbar, defineOverscroll, definePageComponents, defineParticles, definePhysicsComponents, definePopover, definePress, defineProgress, definePullRefresh, defineRating, defineReveal, defineRevealComponents, defineRipple, defineScramble, defineScrollHighlight, defineScrollProgress, defineScrolly, defineShimmerText, defineSkeleton, defineSlider, defineSpinner, defineSplash, defineSplitText, defineSpotlight, defineSpring, defineStagger, defineStickyStack, defineTabs, defineTextComponents, defineTextRotate, defineTilt, defineToaster, defineToggle, defineTooltip, defineTransitionComponents, defineTypewriter, defineUiComponents, defineViewSwitch, defineWaterRipple, defineWaveText, easeOutExpo, enableMpaTransitions, flip, fluentPreset, getMotionIntensity, haptic, linearEasing, loadingBar, morphPath, pageTransition, prefersReducedMotion, projectInertia, readScrollProgress, resolveSpring, restoreMotionIntensity, revealKeyframes, rubberBand, scrambleFrame, scrollToTarget, setMotionIntensity, setVariant, shake, smoothScroll, snapTo, spring, springEasing, springEffectKeyframes, springSamples, stepSpring, supportsLinearEasing, supportsViewTransitions, themeTransition, toast, viewTransition };
|
|
1800
|
-
export type { AmbientEffect, BurstOptions, ButtonDeform, ButtonShape, ButtonState, CardEffect, ClickEffect, ComponentCategory, ComponentsConfig, ConfettiOptions, ConnectedOptions, CursorMode, DialogVariant, FlipOptions, FluentPresetOptions, MotionIntensity, PageEffect, PageTransitionOptions, Placement, RevealEffect, SmoothScrollOptions, SpinnerVariant, SpringConfig, SpringEffect, SpringInput, SpringPreset, SpringValue, SpringValueOptions, ToastHandle, ToastOptions, ToastType, UsaAccordionElement, UsaAcrylicElement, UsaAmbientElement, UsaAuroraElement, UsaAutoSkeletonElement, UsaAvatarStackElement, UsaBackToTopElement, UsaBadgeElement, UsaBlobsElement, UsaBottomSheetElement, UsaButtonElement, UsaCardElement, UsaCardStackElement, UsaCarousel3dElement, UsaCheckElement, UsaCheckboxElement, UsaClickElement, UsaCounterElement, UsaCursorElement, UsaDialogElement, UsaDotNetworkElement, UsaDoubleTapElement, UsaDraggableElement, UsaDrawerElement, UsaElement, UsaFabElement, UsaFlipListElement, UsaFullpageElement, UsaGlitchElement, UsaGradientTextElement, UsaGrainElement, UsaGridGlowElement, UsaHandwritingElement, UsaHoldElement, UsaIconMorphElement, UsaLikeElement, UsaLoadingBarElement, UsaMagneticElement, UsaMarqueeElement, UsaMotionSwitchElement, UsaNavbarElement, UsaOverscrollElement, UsaParticlesElement, UsaPopoverElement, UsaPressElement, UsaProgressElement, UsaPullRefreshElement, UsaRatingElement, UsaRevealElement, UsaRippleElement, UsaScrambleElement, UsaScrollHighlightElement, UsaScrollProgressElement, UsaScrollyElement, UsaShimmerTextElement, UsaSkeletonElement, UsaSliderElement, UsaSpinnerElement, UsaSplashElement, UsaSplitTextElement, UsaSpotlightElement, UsaSpringElement, UsaStaggerElement, UsaStickyStackElement, UsaTabsElement, UsaTextRotateElement, UsaTiltElement, UsaToasterElement, UsaToggleElement, UsaTooltipElement, UsaTypewriterElement, UsaViewSwitchElement, UsaWaterRippleElement, UsaWaveTextElement, Variant, ViewTransitionOptions };
|
|
2040
|
+
export { AMBIENT_EFFECTS, BUTTON_DEFORMS, CARD_EFFECTS, CLICK_EFFECTS, COMPONENT_CATEGORIES, CURSOR_MODES, MORPH_ICONS, MOTION_SCALE, PAGE_EFFECTS, REVEAL_EFFECTS, SPINNER_VARIANTS, SPRING_EFFECTS, SPRING_PRESETS, TIMELINE_PRESETS, VARIANTS, adoptVariants, burst, confetti, configureComponents, connectedAnimation, createSpring, defineAccordion, defineAcrylic, defineAmbient, defineAurora, defineAutoSkeleton, defineAvatarStack, defineBackToTop, defineBackgroundComponents, defineBadge, defineBlobs, defineBottomSheet, defineButton, defineCard, defineCardComponents, defineCardStack, defineCarousel3d, defineCheck, defineCheckbox, defineClick, defineClickComponents, defineComponents, defineCounter, defineCursor, defineDialog, defineDotNetwork, defineDoubleTap, defineDraggable, defineDrawer, defineFab, defineFeedbackComponents, defineFlipList, defineFullpage, defineGestureComponents, defineGlitch, defineGradientText, defineGrain, defineGridGlow, defineHandwriting, defineHold, defineIconMorph, defineInteractionComponents, defineLike, defineLoadingBar, defineMagnetic, defineMarquee, defineMotionSwitch, defineNavbar, defineOverscroll, definePageComponents, defineParticles, definePhysicsComponents, definePinchZoom, definePopover, definePress, defineProgress, definePullRefresh, defineRating, defineReveal, defineRevealComponents, defineRipple, defineScramble, defineScrollHighlight, defineScrollProgress, defineScrolly, defineShimmerText, defineSkeleton, defineSlider, defineSpinner, defineSplash, defineSplitText, defineSpotlight, defineSpring, defineStagger, defineStickyStack, defineSwipeable, defineTabs, defineTextComponents, defineTextRotate, defineTilt, defineTimeline, defineTimelineComponents, defineToaster, defineToggle, defineTooltip, defineTransitionComponents, defineTypewriter, defineUiComponents, defineViewSwitch, defineWaterRipple, defineWaveText, easeOutExpo, enableMpaTransitions, flip, fluentPreset, gesture, getMotionIntensity, haptic, linearEasing, loadingBar, morphPath, pageTransition, pinchScale, prefersReducedMotion, projectInertia, readScrollProgress, resolvePosition, resolveSpring, restoreMotionIntensity, revealKeyframes, rubberBand, scrambleFrame, scrollToTarget, setMotionIntensity, setVariant, shake, smoothScroll, snapTo, spring, springEasing, springEffectKeyframes, springSamples, stepSpring, supportsLinearEasing, supportsViewTransitions, swipeDirection, themeTransition, timeline, toast, viewTransition };
|
|
2041
|
+
export type { AmbientEffect, BurstOptions, ButtonDeform, ButtonShape, ButtonState, CardEffect, ClickEffect, ComponentCategory, ComponentsConfig, ConfettiOptions, ConnectedOptions, CursorMode, DialogVariant, FlipOptions, FluentPresetOptions, GestureHandlers, GestureOptions, MotionIntensity, PageEffect, PageTransitionOptions, PanState, PinchState, Placement, PressState, RevealEffect, ScrubOptions, SmoothScrollOptions, SpinnerVariant, SpringConfig, SpringEffect, SpringInput, SpringPreset, SpringValue, SpringValueOptions, SwipeDirection, SwipeState, Timeline, TimelineOptions, TimelinePosition, TimelineStepOptions, ToastHandle, ToastOptions, ToastType, UsaAccordionElement, UsaAcrylicElement, UsaAmbientElement, UsaAuroraElement, UsaAutoSkeletonElement, UsaAvatarStackElement, UsaBackToTopElement, UsaBadgeElement, UsaBlobsElement, UsaBottomSheetElement, UsaButtonElement, UsaCardElement, UsaCardStackElement, UsaCarousel3dElement, UsaCheckElement, UsaCheckboxElement, UsaClickElement, UsaCounterElement, UsaCursorElement, UsaDialogElement, UsaDotNetworkElement, UsaDoubleTapElement, UsaDraggableElement, UsaDrawerElement, UsaElement, UsaFabElement, UsaFlipListElement, UsaFullpageElement, UsaGlitchElement, UsaGradientTextElement, UsaGrainElement, UsaGridGlowElement, UsaHandwritingElement, UsaHoldElement, UsaIconMorphElement, UsaLikeElement, UsaLoadingBarElement, UsaMagneticElement, UsaMarqueeElement, UsaMotionSwitchElement, UsaNavbarElement, UsaOverscrollElement, UsaParticlesElement, UsaPinchZoomElement, UsaPopoverElement, UsaPressElement, UsaProgressElement, UsaPullRefreshElement, UsaRatingElement, UsaRevealElement, UsaRippleElement, UsaScrambleElement, UsaScrollHighlightElement, UsaScrollProgressElement, UsaScrollyElement, UsaShimmerTextElement, UsaSkeletonElement, UsaSliderElement, UsaSpinnerElement, UsaSplashElement, UsaSplitTextElement, UsaSpotlightElement, UsaSpringElement, UsaStaggerElement, UsaStickyStackElement, UsaSwipeableElement, UsaTabsElement, UsaTextRotateElement, UsaTiltElement, UsaTimelineElement, UsaToasterElement, UsaToggleElement, UsaTooltipElement, UsaTypewriterElement, UsaViewSwitchElement, UsaWaterRippleElement, UsaWaveTextElement, Variant, ViewTransitionOptions };
|
package/dist/components.js
CHANGED
|
@@ -20,12 +20,16 @@ import { defineUiComponents } from './components/ui.js';
|
|
|
20
20
|
export { defineAvatarStack, defineBadge, defineBottomSheet, defineDrawer, defineFab, defineNavbar, definePopover, definePullRefresh, defineRating, defineSlider, defineTabs, defineTooltip } from './components/ui.js';
|
|
21
21
|
import { definePageComponents } from './components/page.js';
|
|
22
22
|
export { AMBIENT_EFFECTS, CURSOR_MODES, PAGE_EFFECTS, defineAmbient, defineAutoSkeleton, defineBackToTop, defineCursor, defineFullpage, defineLoadingBar, defineMotionSwitch, defineSplash, enableMpaTransitions, loadingBar, pageTransition, restoreMotionIntensity, scrollToTarget, setMotionIntensity, smoothScroll, supportsViewTransitions, themeTransition } from './components/page.js';
|
|
23
|
-
import {
|
|
24
|
-
export {
|
|
25
|
-
import {
|
|
26
|
-
export {
|
|
27
|
-
|
|
28
|
-
export {
|
|
23
|
+
import { defineTimelineComponents } from './components/timeline.js';
|
|
24
|
+
export { TIMELINE_PRESETS, defineTimeline, resolvePosition, timeline } from './components/timeline.js';
|
|
25
|
+
import { defineGestureComponents } from './components/gesture.js';
|
|
26
|
+
export { definePinchZoom, defineSwipeable, gesture, pinchScale, swipeDirection } from './components/gesture.js';
|
|
27
|
+
import { a as adoptVariants } from './chunks/variants-BQ3gCb5L.js';
|
|
28
|
+
export { V as VARIANTS, s as setVariant } from './chunks/variants-BQ3gCb5L.js';
|
|
29
|
+
import { c as canDefine } from './chunks/base-Cu-86Z31.js';
|
|
30
|
+
export { M as MOTION_SCALE, a as configureComponents, g as getMotionIntensity, p as prefersReducedMotion } from './chunks/base-Cu-86Z31.js';
|
|
31
|
+
export { C as COMPONENT_CATEGORIES } from './chunks/index-tags-DZ-gjMZc.js';
|
|
32
|
+
export { S as SPRING_PRESETS, c as createSpring, l as linearEasing, p as projectInertia, r as resolveSpring, a as rubberBand, s as snapTo, b as spring, d as springEasing, e as springSamples, f as stepSpring, g as supportsLinearEasing } from './chunks/spring-BV-cpTHC.js';
|
|
29
33
|
|
|
30
34
|
/**
|
|
31
35
|
* use-scroll-animate/components
|
|
@@ -59,6 +63,8 @@ const BY_CATEGORY = {
|
|
|
59
63
|
click: defineClickComponents,
|
|
60
64
|
ui: defineUiComponents,
|
|
61
65
|
page: definePageComponents,
|
|
66
|
+
timeline: defineTimelineComponents,
|
|
67
|
+
gesture: defineGestureComponents,
|
|
62
68
|
};
|
|
63
69
|
/**
|
|
64
70
|
* Register every `<usa-*>` component (or only the given categories).
|
|
@@ -70,5 +76,5 @@ function defineComponents(categories) {
|
|
|
70
76
|
(categories || Object.keys(BY_CATEGORY)).forEach((c) => BY_CATEGORY[c]?.());
|
|
71
77
|
}
|
|
72
78
|
|
|
73
|
-
export { adoptVariants, defineBackgroundComponents, defineCardComponents, defineClickComponents, defineComponents, defineFeedbackComponents, defineInteractionComponents, definePageComponents, definePhysicsComponents, defineRevealComponents, defineTextComponents, defineTransitionComponents, defineUiComponents };
|
|
79
|
+
export { adoptVariants, defineBackgroundComponents, defineCardComponents, defineClickComponents, defineComponents, defineFeedbackComponents, defineGestureComponents, defineInteractionComponents, definePageComponents, definePhysicsComponents, defineRevealComponents, defineTextComponents, defineTimelineComponents, defineTransitionComponents, defineUiComponents };
|
|
74
80
|
//# sourceMappingURL=components.js.map
|
package/dist/components.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"components.js","sources":["../src/components/index.ts"],"sourcesContent":["/**\n * use-scroll-animate/components\n *\n * Framework-agnostic, dependency-free animated UI components built on\n * Custom Elements + CSS + the Web Animations API. They run in any browser\n * and in Windows desktop apps that render with a web view: Electron, Tauri\n * (WebView2), WinUI 3 / WPF / WinForms with WebView2, and installed PWAs.\n *\n * ```js\n * import { defineComponents } from 'use-scroll-animate/components';\n * defineComponents(); // registers every <usa-*> element\n * // or only what you use (tree-shakable):\n * import { defineTypewriter } from 'use-scroll-animate/components/text';\n * ```\n *\n * Importing has no side effects and is SSR-safe; nothing is registered\n * until a `define*()` function runs in a browser.\n *\n * @license MIT\n */\nimport { defineRevealComponents } from './reveal/index';\nimport { defineTextComponents } from './text/index';\nimport { defineInteractionComponents } from './interaction/index';\nimport { defineFeedbackComponents } from './feedback/index';\nimport { defineBackgroundComponents } from './background/index';\nimport { defineTransitionComponents } from './transitions/index';\nimport { definePhysicsComponents } from './physics/index';\nimport { defineCardComponents } from './cards/index';\nimport { defineClickComponents } from './click/index';\nimport { defineUiComponents } from './ui/index';\nimport { definePageComponents } from './page/index';\nimport { adoptVariants } from './ui/variants';\nimport { canDefine } from './base';\n\nexport * from './reveal/index';\nexport * from './text/index';\nexport * from './interaction/index';\nexport * from './feedback/index';\nexport * from './background/index';\nexport * from './transitions/index';\nexport * from './physics/index';\nexport * from './cards/index';\nexport * from './click/index';\nexport * from './ui/index';\nexport * from './page/index';\n\nexport { COMPONENT_CATEGORIES } from './index-tags';\nexport type { ComponentCategory } from './index-tags';\nimport { COMPONENT_CATEGORIES, type ComponentCategory } from './index-tags';\n\nconst BY_CATEGORY: Record<ComponentCategory, () => void> = {\n reveal: defineRevealComponents,\n text: defineTextComponents,\n interaction: defineInteractionComponents,\n feedback: defineFeedbackComponents,\n background: defineBackgroundComponents,\n transitions: defineTransitionComponents,\n physics: definePhysicsComponents,\n cards: defineCardComponents,\n click: defineClickComponents,\n ui: defineUiComponents,\n page: definePageComponents,\n};\n\n/**\n * Register every `<usa-*>` component (or only the given categories).\n * Safe to call more than once and on the server (no-op without DOM).\n */\nexport function defineComponents(categories?: ComponentCategory[]): void {\n if (canDefine()) adoptVariants();\n (categories || (Object.keys(BY_CATEGORY) as ComponentCategory[])).forEach((c) => BY_CATEGORY[c]?.());\n}\n"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"components.js","sources":["../src/components/index.ts"],"sourcesContent":["/**\n * use-scroll-animate/components\n *\n * Framework-agnostic, dependency-free animated UI components built on\n * Custom Elements + CSS + the Web Animations API. They run in any browser\n * and in Windows desktop apps that render with a web view: Electron, Tauri\n * (WebView2), WinUI 3 / WPF / WinForms with WebView2, and installed PWAs.\n *\n * ```js\n * import { defineComponents } from 'use-scroll-animate/components';\n * defineComponents(); // registers every <usa-*> element\n * // or only what you use (tree-shakable):\n * import { defineTypewriter } from 'use-scroll-animate/components/text';\n * ```\n *\n * Importing has no side effects and is SSR-safe; nothing is registered\n * until a `define*()` function runs in a browser.\n *\n * @license MIT\n */\nimport { defineRevealComponents } from './reveal/index';\nimport { defineTextComponents } from './text/index';\nimport { defineInteractionComponents } from './interaction/index';\nimport { defineFeedbackComponents } from './feedback/index';\nimport { defineBackgroundComponents } from './background/index';\nimport { defineTransitionComponents } from './transitions/index';\nimport { definePhysicsComponents } from './physics/index';\nimport { defineCardComponents } from './cards/index';\nimport { defineClickComponents } from './click/index';\nimport { defineUiComponents } from './ui/index';\nimport { definePageComponents } from './page/index';\nimport { defineTimelineComponents } from './timeline/index';\nimport { defineGestureComponents } from './gesture/index';\nimport { adoptVariants } from './ui/variants';\nimport { canDefine } from './base';\n\nexport * from './reveal/index';\nexport * from './text/index';\nexport * from './interaction/index';\nexport * from './feedback/index';\nexport * from './background/index';\nexport * from './transitions/index';\nexport * from './physics/index';\nexport * from './cards/index';\nexport * from './click/index';\nexport * from './ui/index';\nexport * from './page/index';\nexport * from './timeline/index';\nexport * from './gesture/index';\n\nexport { COMPONENT_CATEGORIES } from './index-tags';\nexport type { ComponentCategory } from './index-tags';\nimport { COMPONENT_CATEGORIES, type ComponentCategory } from './index-tags';\n\nconst BY_CATEGORY: Record<ComponentCategory, () => void> = {\n reveal: defineRevealComponents,\n text: defineTextComponents,\n interaction: defineInteractionComponents,\n feedback: defineFeedbackComponents,\n background: defineBackgroundComponents,\n transitions: defineTransitionComponents,\n physics: definePhysicsComponents,\n cards: defineCardComponents,\n click: defineClickComponents,\n ui: defineUiComponents,\n page: definePageComponents,\n timeline: defineTimelineComponents,\n gesture: defineGestureComponents,\n};\n\n/**\n * Register every `<usa-*>` component (or only the given categories).\n * Safe to call more than once and on the server (no-op without DOM).\n */\nexport function defineComponents(categories?: ComponentCategory[]): void {\n if (canDefine()) adoptVariants();\n (categories || (Object.keys(BY_CATEGORY) as ComponentCategory[])).forEach((c) => BY_CATEGORY[c]?.());\n}\n"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;;;;;;;;;;;;;AAmBG;AAmCH,MAAM,WAAW,GAA0C;AACzD,IAAA,MAAM,EAAE,sBAAsB;AAC9B,IAAA,IAAI,EAAE,oBAAoB;AAC1B,IAAA,WAAW,EAAE,2BAA2B;AACxC,IAAA,QAAQ,EAAE,wBAAwB;AAClC,IAAA,UAAU,EAAE,0BAA0B;AACtC,IAAA,WAAW,EAAE,0BAA0B;AACvC,IAAA,OAAO,EAAE,uBAAuB;AAChC,IAAA,KAAK,EAAE,oBAAoB;AAC3B,IAAA,KAAK,EAAE,qBAAqB;AAC5B,IAAA,EAAE,EAAE,kBAAkB;AACtB,IAAA,IAAI,EAAE,oBAAoB;AAC1B,IAAA,QAAQ,EAAE,wBAAwB;AAClC,IAAA,OAAO,EAAE,uBAAuB;CACjC;AAED;;;AAGG;AACG,SAAU,gBAAgB,CAAC,UAAgC,EAAA;AAC/D,IAAA,IAAI,SAAS,EAAE;AAAE,QAAA,aAAa,EAAE;IAChC,CAAC,UAAU,IAAK,MAAM,CAAC,IAAI,CAAC,WAAW,CAAyB,EAAE,OAAO,CAAC,CAAC,CAAC,KAAK,WAAW,CAAC,CAAC,CAAC,IAAI,CAAC;AACtG;;;;"}
|