use-scroll-animate 2.3.0 → 2.5.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -898,6 +898,320 @@ declare global {
898
898
  }
899
899
  }
900
900
 
901
+ declare const CARD_EFFECTS: readonly ["flip", "holo", "glass", "border-glow", "conic-border", "lift", "spotlight", "sheen", "parallax-layers", "expand"];
902
+ type CardEffect = (typeof CARD_EFFECTS)[number];
903
+ /**
904
+ * `<usa-card>` — card effects, combinable: `effect="lift sheen"`.
905
+ *
906
+ * - `flip` — front/back (`[data-front]` / `[data-back]` children) flip on
907
+ * hover or `trigger="click"`, `axis="y"` (default, horizontal flip) or `x`.
908
+ * - `holo` — holographic foil that shifts with the pointer.
909
+ * - `glass` — frosted glass surface (backdrop blur).
910
+ * - `border-glow` — a glow on the border that follows the pointer.
911
+ * - `conic-border` — a rotating conic-gradient border.
912
+ * - `lift` — rises with a deeper shadow and a slight pointer tilt.
913
+ * - `spotlight` — a soft light that follows the pointer.
914
+ * - `sheen` — a light sweep across the card on hover / focus.
915
+ * - `parallax-layers` — children with `data-depth="0.2…1"` move at different depths.
916
+ * - `expand` — click to grow into a full detail view (`[data-detail]`
917
+ * content is shown), FLIP + spring; Esc, `[data-close]` or the backdrop closes.
918
+ *
919
+ * Attributes: `effect`, `axis`, `trigger`, `depth` (parallax px, 16),
920
+ * `color` (glow / spotlight colour), `flipped`, `expanded`, `disabled`.
921
+ * CSS variables: `--usa-card-x/-y` (pointer %, 0–100), `--usa-card-nx/-ny` (−1…1).
922
+ * Methods: `flip(force?)`, `expand()`, `collapse()`. Events: `usa:flip`,
923
+ * `usa:expand`, `usa:collapse`. Reduced motion: no tilt / parallax / sweep;
924
+ * flips and expansions cross-fade.
925
+ */
926
+ interface UsaCardElement extends UsaElement {
927
+ readonly effects: string[];
928
+ flipped: boolean;
929
+ readonly expanded: boolean;
930
+ flip(force?: boolean): void;
931
+ expand(): Promise<void>;
932
+ collapse(): Promise<void>;
933
+ }
934
+ declare function defineCard(tag?: string): CustomElementConstructor | undefined;
935
+
936
+ /**
937
+ * `<usa-card-stack>` — a deck of cards (its element children). The top card
938
+ * can be swiped away left or right (pointer, touch or arrow keys); the rest
939
+ * fan out behind it and move up with a spring.
940
+ *
941
+ * Attributes: `threshold` (px to dismiss, 90), `visible` (cards fanned
942
+ * behind, 3), `offset` (px between cards, 10), `loop` (swiped cards go back
943
+ * to the bottom), `disabled`. Methods: `swipe(direction)`, `top`. Events:
944
+ * `usa:swipe` (`{ direction: 'left' | 'right', card }`), `usa:empty`.
945
+ * Reduced motion: cards are removed instantly, no rotation.
946
+ */
947
+ interface UsaCardStackElement extends UsaElement {
948
+ readonly top: HTMLElement | null;
949
+ swipe(direction: 'left' | 'right'): Promise<void>;
950
+ }
951
+ declare function defineCardStack(tag?: string): CustomElementConstructor | undefined;
952
+
953
+ /**
954
+ * `<usa-sticky-stack>` — cards (element children) stick to the top while
955
+ * scrolling and the ones underneath scale down and dim as the next card
956
+ * slides over them, like a deck building up.
957
+ *
958
+ * Attributes: `top` (px from the viewport top, 80), `gap` (px each card
959
+ * peeks below the previous, 16), `scale` (how much a covered card shrinks,
960
+ * 0.06). Reduced motion: cards still stack (sticky) but do not scale.
961
+ */
962
+ interface UsaStickyStackElement extends UsaElement {
963
+ update(): void;
964
+ }
965
+ declare function defineStickyStack(tag?: string): CustomElementConstructor | undefined;
966
+
967
+ /**
968
+ * `<usa-carousel-3d>` — its element children on a 3D ring. Rotate with the
969
+ * arrow keys, a drag/swipe, the wheel (shift) or `next()` / `prev()`; the
970
+ * front item is `aria-current`. Spring-driven rotation.
971
+ *
972
+ * Attributes: `radius` (px, auto from item width), `autoplay` (ms between
973
+ * steps, pauses on hover/focus), `perspective` (px, 1200), `index`.
974
+ * Events: `usa:change` (`{ index }`). Reduced motion: a flat, instant
975
+ * switch (only the current item is shown, others dimmed).
976
+ */
977
+ interface UsaCarousel3dElement extends UsaElement {
978
+ index: number;
979
+ next(): void;
980
+ prev(): void;
981
+ goTo(i: number): void;
982
+ }
983
+ declare function defineCarousel3d(tag?: string): CustomElementConstructor | undefined;
984
+
985
+ /**
986
+ * use-scroll-animate/components/cards — card effects (v2.4).
987
+ * `<usa-card effect="flip | holo | glass | border-glow | conic-border | lift |
988
+ * spotlight | sheen | parallax-layers | expand">` (combinable),
989
+ * `<usa-card-stack>` (swipeable deck), `<usa-sticky-stack>` (stacking on
990
+ * scroll) and `<usa-carousel-3d>`.
991
+ */
992
+
993
+ /** Register every component of this category under its default tag. */
994
+ declare function defineCardComponents(): void;
995
+ declare global {
996
+ interface HTMLElementTagNameMap {
997
+ 'usa-card': UsaCardElement;
998
+ 'usa-card-stack': UsaCardStackElement;
999
+ 'usa-sticky-stack': UsaStickyStackElement;
1000
+ 'usa-carousel-3d': UsaCarousel3dElement;
1001
+ }
1002
+ }
1003
+
1004
+ declare const CLICK_EFFECTS: readonly ["ripple", "burst", "confetti", "squish", "press-spring", "shake"];
1005
+ type ClickEffect = (typeof CLICK_EFFECTS)[number];
1006
+ /**
1007
+ * `<usa-click>` — click / tap effects on whatever it wraps (combinable:
1008
+ * `effect="press-spring burst"`).
1009
+ *
1010
+ * - `ripple` — an ink wave from the pointer (enhanced: `color`, soft edge);
1011
+ * - `burst` — particles radiating from the pointer (`shape`: circle, square, star, heart, emoji);
1012
+ * - `confetti` — a confetti cannon from the click point;
1013
+ * - `squish` — squash on press, stretch on release (spring);
1014
+ * - `press-spring` — dips while pressed, springs back with overshoot;
1015
+ * - `shake` — horizontal error shake; plays on `invalid` events from a form
1016
+ * inside, on `shake()`, or on click when `trigger="click"`.
1017
+ *
1018
+ * Attributes: `effect`, `color`, `shape`, `count`, `haptic` (vibrate ms,
1019
+ * where supported), `disabled`. Keyboard (Space/Enter) triggers the effects
1020
+ * from the centre. Reduced motion: no particles or movement; press dims.
1021
+ */
1022
+ interface UsaClickElement extends UsaElement {
1023
+ readonly effects: string[];
1024
+ play(x?: number, y?: number): void;
1025
+ shake(): void;
1026
+ }
1027
+ declare function defineClick(tag?: string): CustomElementConstructor | undefined;
1028
+
1029
+ declare const BUTTON_DEFORMS: readonly ["squash", "wobble", "gooey", "dent"];
1030
+ type ButtonDeform = (typeof BUTTON_DEFORMS)[number];
1031
+ type ButtonShape = 'pill' | 'circle' | 'icon';
1032
+ type ButtonState = 'idle' | 'loading' | 'success' | 'error';
1033
+ /**
1034
+ * `<usa-button>` — **button click deformation** (按钮点击形变) around a
1035
+ * native `<button>` (or `<a>`) child — or the element itself becomes a button.
1036
+ *
1037
+ * `deform` (combinable, e.g. `deform="squash wobble"`):
1038
+ * - `squash` — squash on press, stretch-and-settle on release (spring);
1039
+ * - `wobble` — elastic border-radius wobble after a click;
1040
+ * - `gooey` — liquid blob: droplets squeeze out from the press point and
1041
+ * merge back (SVG goo filter);
1042
+ * - `dent` — the surface dents toward the pressed point (3D tilt + inner shade).
1043
+ *
1044
+ * `shape="pill | circle | icon"` morphs the outline with a spring (label =
1045
+ * `[data-label]`, icon = `[data-icon]` children); `morphTo(shape)`.
1046
+ *
1047
+ * `morph="submit"` — click → `loading` (shrinks to a circle with a spinner,
1048
+ * `aria-busy`), then `success` (check) or `error` (shake + cross), and back
1049
+ * to `idle` after `reset` ms (1800). Drive it with `state="…"` / `.state`, or
1050
+ * call `event.detail.done(ok)` from a `usa:submit` listener.
1051
+ *
1052
+ * Attributes: `deform`, `shape`, `morph`, `state`, `reset`, `haptic`,
1053
+ * `disabled`. Events: `usa:submit`, `usa:state`. Reduced motion: no
1054
+ * deformation; shape and state changes are instant; status still announced.
1055
+ */
1056
+ interface UsaButtonElement extends UsaElement {
1057
+ readonly target: HTMLElement;
1058
+ shape: ButtonShape;
1059
+ state: ButtonState;
1060
+ morphTo(shape: ButtonShape): Promise<void>;
1061
+ }
1062
+ declare function defineButton(tag?: string): CustomElementConstructor | undefined;
1063
+
1064
+ type Pt = [number, number];
1065
+ type Quad = [Pt, Pt, Pt, Pt];
1066
+ /**
1067
+ * Morphable icons: every icon is three quads (four points each) on a 24×24
1068
+ * grid, so any icon can morph into any other by interpolating points.
1069
+ */
1070
+ declare const MORPH_ICONS: Record<string, [Quad, Quad, Quad]>;
1071
+ /** SVG path data for an icon, or for the interpolation `t` (0–1) between two. */
1072
+ declare function morphPath(from: string, to?: string, t?: number): string;
1073
+ /**
1074
+ * `<usa-icon-morph>` — an icon that morphs between shapes with a spring:
1075
+ * play ↔ pause, menu ↔ close, plus ↔ minus, check, arrow-right…
1076
+ *
1077
+ * Attributes: `icons` (comma list, cycled; default `play,pause`), `index`
1078
+ * (current, 0), `size` (px, 24), `toggle` (makes it a button that cycles
1079
+ * on click / Enter / Space), `labels` (comma list of accessible names per
1080
+ * icon, e.g. `Play,Pause`), `preset` (spring, `wobbly`). Methods:
1081
+ * `next()`, `show(nameOrIndex)`. Events: `usa:change` (`{ index, icon }`).
1082
+ * Inside a `<usa-button>` or `<button>` it is decorative. Reduced motion:
1083
+ * the icon switches instantly.
1084
+ */
1085
+ interface UsaIconMorphElement extends UsaElement {
1086
+ index: number;
1087
+ readonly icon: string;
1088
+ next(): void;
1089
+ show(icon: string | number): void;
1090
+ }
1091
+ declare function defineIconMorph(tag?: string): CustomElementConstructor | undefined;
1092
+
1093
+ /**
1094
+ * `<usa-like>` — a like / favourite toggle: the heart pops with a spring and
1095
+ * bursts into particles when liked. `role="button"` + `aria-pressed`.
1096
+ *
1097
+ * Attributes: `liked`, `count` (shown next to the heart, updated ±1),
1098
+ * `label` (accessible name, default "Like"), `color`, `size` (px, 24),
1099
+ * `haptic`, `disabled`. Events: `change`, `usa:change` (`{ liked, count }`).
1100
+ * Reduced motion: colour change only.
1101
+ */
1102
+ interface UsaLikeElement extends UsaElement {
1103
+ liked: boolean;
1104
+ count: number | null;
1105
+ toggle(force?: boolean): void;
1106
+ }
1107
+ declare function defineLike(tag?: string): CustomElementConstructor | undefined;
1108
+
1109
+ /**
1110
+ * `<usa-hold>` — hold-to-confirm: press and hold (pointer, Space or Enter)
1111
+ * while a progress ring fills; releasing early rewinds it. Good for
1112
+ * destructive actions.
1113
+ *
1114
+ * Attributes: `duration` (ms, 1200), `label` (accessible name), `color`,
1115
+ * `disabled`. CSS variable `--usa-hold` (0–1). Events: `usa:progress`,
1116
+ * `usa:confirm`, `usa:cancel`. Reduced motion: same timing, the ring fills
1117
+ * without the scale pulse.
1118
+ */
1119
+ interface UsaHoldElement extends UsaElement {
1120
+ readonly progress: number;
1121
+ cancel(): void;
1122
+ }
1123
+ declare function defineHold(tag?: string): CustomElementConstructor | undefined;
1124
+
1125
+ /**
1126
+ * `<usa-double-tap>` — detects a double tap / double click on its content
1127
+ * (photos, posts) and pops a heart (or `icon`) at the tap point.
1128
+ *
1129
+ * Attributes: `icon` (text / emoji, default ♥), `color`, `delay` (max ms
1130
+ * between taps, 300), `haptic`, `disabled`. Events: `usa:double-tap`
1131
+ * (`{ x, y }`, element-relative). Keyboard users: press `L` while focused.
1132
+ * Reduced motion: the icon fades in and out without scaling or particles.
1133
+ */
1134
+ interface UsaDoubleTapElement extends UsaElement {
1135
+ pop(x?: number, y?: number): void;
1136
+ }
1137
+ declare function defineDoubleTap(tag?: string): CustomElementConstructor | undefined;
1138
+
1139
+ /**
1140
+ * `<usa-checkbox>` — an animated, form-associated checkbox: the box springs
1141
+ * and the check mark draws itself. `role="checkbox"` + `aria-checked`
1142
+ * (`mixed` with `indeterminate`).
1143
+ *
1144
+ * Attributes: `checked`, `indeterminate`, `disabled`, `name`, `value`
1145
+ * (`on`), `label`, `shape` (`square` default, `circle`). Events: `change`,
1146
+ * `usa:change` (`{ checked }`). Reduced motion: no spring or drawing.
1147
+ */
1148
+ interface UsaCheckboxElement extends UsaElement {
1149
+ checked: boolean;
1150
+ indeterminate: boolean;
1151
+ toggle(force?: boolean): void;
1152
+ }
1153
+ declare function defineCheckbox(tag?: string): CustomElementConstructor | undefined;
1154
+
1155
+ interface BurstOptions {
1156
+ /** Number of particles (default 12). */
1157
+ count?: number;
1158
+ /** Colours to pick from (default: accent palette). */
1159
+ colors?: string[];
1160
+ /** Travel distance in px (default 48). */
1161
+ distance?: number;
1162
+ /** Particle size in px (default 6). */
1163
+ size?: number;
1164
+ /** `circle` (default), `square`, `star`, `heart` or any text / emoji. */
1165
+ shape?: 'circle' | 'square' | 'star' | 'heart' | string;
1166
+ /** Duration in ms (default 600). */
1167
+ duration?: number;
1168
+ }
1169
+ /** Particles radiating from client point (x, y). Returns the number spawned. */
1170
+ declare function burst(x: number, y: number, options?: BurstOptions): number;
1171
+ interface ConfettiOptions {
1172
+ /** Origin in client px (default: centre-bottom third of the viewport). */
1173
+ x?: number;
1174
+ y?: number;
1175
+ /** Pieces (default 80). */
1176
+ count?: number;
1177
+ /** Spread angle in degrees (default 70). */
1178
+ spread?: number;
1179
+ /** Launch speed multiplier (default 1). */
1180
+ velocity?: number;
1181
+ colors?: string[];
1182
+ /** Duration in ms (default 1600). */
1183
+ duration?: number;
1184
+ }
1185
+ /** A confetti cannon (paper pieces with gravity, drift and spin). */
1186
+ declare function confetti(options?: ConfettiOptions): number;
1187
+ /** Horizontal error shake (`intensity` px, default 8). Reduced motion: a red outline flash. */
1188
+ declare function shake(el: Element, intensity?: number, duration?: number): Animation | null;
1189
+ /** `navigator.vibrate()` where supported (Android Chrome, some WebViews). Returns whether it ran. */
1190
+ declare function haptic(pattern?: number | number[]): boolean;
1191
+
1192
+ /**
1193
+ * use-scroll-animate/components/click — click & tap effects (v2.5).
1194
+ * `<usa-click>` (ripple, burst, confetti, squish, press-spring, shake),
1195
+ * `<usa-button>` (button click deformation: squash, wobble, gooey, dent;
1196
+ * shape morph; submit → loading → success), `<usa-icon-morph>`,
1197
+ * `<usa-like>`, `<usa-hold>`, `<usa-double-tap>`, `<usa-checkbox>`, plus
1198
+ * `burst()`, `confetti()`, `shake()` and `haptic()`.
1199
+ */
1200
+
1201
+ /** Register every component of this category under its default tag. */
1202
+ declare function defineClickComponents(): void;
1203
+ declare global {
1204
+ interface HTMLElementTagNameMap {
1205
+ 'usa-click': UsaClickElement;
1206
+ 'usa-button': UsaButtonElement;
1207
+ 'usa-icon-morph': UsaIconMorphElement;
1208
+ 'usa-like': UsaLikeElement;
1209
+ 'usa-hold': UsaHoldElement;
1210
+ 'usa-double-tap': UsaDoubleTapElement;
1211
+ 'usa-checkbox': UsaCheckboxElement;
1212
+ }
1213
+ }
1214
+
901
1215
  /** The component categories and their default tags. */
902
1216
  declare const COMPONENT_CATEGORIES: {
903
1217
  readonly reveal: readonly ["usa-reveal", "usa-stagger", "usa-scroll-progress", "usa-scrolly"];
@@ -907,6 +1221,8 @@ declare const COMPONENT_CATEGORIES: {
907
1221
  readonly background: readonly ["usa-aurora", "usa-particles", "usa-grain", "usa-marquee", "usa-acrylic"];
908
1222
  readonly transitions: readonly ["usa-dialog", "usa-accordion", "usa-flip-list", "usa-view-switch"];
909
1223
  readonly physics: readonly ["usa-spring", "usa-draggable", "usa-overscroll"];
1224
+ readonly cards: readonly ["usa-card", "usa-card-stack", "usa-sticky-stack", "usa-carousel-3d"];
1225
+ readonly click: readonly ["usa-click", "usa-button", "usa-icon-morph", "usa-like", "usa-hold", "usa-double-tap", "usa-checkbox"];
910
1226
  };
911
1227
  type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
912
1228
  /**
@@ -915,5 +1231,5 @@ type ComponentCategory = keyof typeof COMPONENT_CATEGORIES;
915
1231
  */
916
1232
  declare function defineComponents(categories?: ComponentCategory[]): void;
917
1233
 
918
- export { COMPONENT_CATEGORIES, REVEAL_EFFECTS, SPINNER_VARIANTS, SPRING_EFFECTS, SPRING_PRESETS, configureComponents, connectedAnimation, createSpring, defineAccordion, defineAcrylic, defineAurora, defineBackgroundComponents, defineCheck, defineComponents, defineCounter, defineDialog, defineDraggable, defineFeedbackComponents, defineFlipList, defineGrain, defineInteractionComponents, defineMagnetic, defineMarquee, defineOverscroll, defineParticles, definePhysicsComponents, definePress, defineProgress, defineReveal, defineRevealComponents, defineRipple, defineScramble, defineScrollProgress, defineScrolly, defineShimmerText, defineSkeleton, defineSpinner, defineSplitText, defineSpotlight, defineSpring, defineStagger, defineTextComponents, defineTextRotate, defineTilt, defineToaster, defineToggle, defineTransitionComponents, defineTypewriter, defineViewSwitch, easeOutExpo, flip, linearEasing, prefersReducedMotion, projectInertia, readScrollProgress, resolveSpring, revealKeyframes, rubberBand, scrambleFrame, snapTo, spring, springEasing, springEffectKeyframes, springSamples, stepSpring, supportsLinearEasing, toast, viewTransition };
919
- export type { ComponentCategory, ComponentsConfig, ConnectedOptions, DialogVariant, FlipOptions, RevealEffect, SpinnerVariant, SpringConfig, SpringEffect, SpringInput, SpringPreset, SpringValue, SpringValueOptions, ToastHandle, ToastOptions, ToastType, UsaAccordionElement, UsaAcrylicElement, UsaAuroraElement, UsaCheckElement, UsaCounterElement, UsaDialogElement, UsaDraggableElement, UsaElement, UsaFlipListElement, UsaGrainElement, UsaMagneticElement, UsaMarqueeElement, UsaOverscrollElement, UsaParticlesElement, UsaPressElement, UsaProgressElement, UsaRevealElement, UsaRippleElement, UsaScrambleElement, UsaScrollProgressElement, UsaScrollyElement, UsaShimmerTextElement, UsaSkeletonElement, UsaSpinnerElement, UsaSplitTextElement, UsaSpotlightElement, UsaSpringElement, UsaStaggerElement, UsaTextRotateElement, UsaTiltElement, UsaToasterElement, UsaToggleElement, UsaTypewriterElement, UsaViewSwitchElement, ViewTransitionOptions };
1234
+ export { BUTTON_DEFORMS, CARD_EFFECTS, CLICK_EFFECTS, COMPONENT_CATEGORIES, MORPH_ICONS, REVEAL_EFFECTS, SPINNER_VARIANTS, SPRING_EFFECTS, SPRING_PRESETS, burst, confetti, configureComponents, connectedAnimation, createSpring, defineAccordion, defineAcrylic, defineAurora, defineBackgroundComponents, defineButton, defineCard, defineCardComponents, defineCardStack, defineCarousel3d, defineCheck, defineCheckbox, defineClick, defineClickComponents, defineComponents, defineCounter, defineDialog, defineDoubleTap, defineDraggable, defineFeedbackComponents, defineFlipList, defineGrain, defineHold, defineIconMorph, defineInteractionComponents, defineLike, defineMagnetic, defineMarquee, defineOverscroll, defineParticles, definePhysicsComponents, definePress, defineProgress, defineReveal, defineRevealComponents, defineRipple, defineScramble, defineScrollProgress, defineScrolly, defineShimmerText, defineSkeleton, defineSpinner, defineSplitText, defineSpotlight, defineSpring, defineStagger, defineStickyStack, defineTextComponents, defineTextRotate, defineTilt, defineToaster, defineToggle, defineTransitionComponents, defineTypewriter, defineViewSwitch, easeOutExpo, flip, haptic, linearEasing, morphPath, prefersReducedMotion, projectInertia, readScrollProgress, resolveSpring, revealKeyframes, rubberBand, scrambleFrame, shake, snapTo, spring, springEasing, springEffectKeyframes, springSamples, stepSpring, supportsLinearEasing, toast, viewTransition };
1235
+ export type { BurstOptions, ButtonDeform, ButtonShape, ButtonState, CardEffect, ClickEffect, ComponentCategory, ComponentsConfig, ConfettiOptions, ConnectedOptions, DialogVariant, FlipOptions, RevealEffect, SpinnerVariant, SpringConfig, SpringEffect, SpringInput, SpringPreset, SpringValue, SpringValueOptions, ToastHandle, ToastOptions, ToastType, UsaAccordionElement, UsaAcrylicElement, UsaAuroraElement, UsaButtonElement, UsaCardElement, UsaCardStackElement, UsaCarousel3dElement, UsaCheckElement, UsaCheckboxElement, UsaClickElement, UsaCounterElement, UsaDialogElement, UsaDoubleTapElement, UsaDraggableElement, UsaElement, UsaFlipListElement, UsaGrainElement, UsaHoldElement, UsaIconMorphElement, UsaLikeElement, UsaMagneticElement, UsaMarqueeElement, UsaOverscrollElement, UsaParticlesElement, UsaPressElement, UsaProgressElement, UsaRevealElement, UsaRippleElement, UsaScrambleElement, UsaScrollProgressElement, UsaScrollyElement, UsaShimmerTextElement, UsaSkeletonElement, UsaSpinnerElement, UsaSplitTextElement, UsaSpotlightElement, UsaSpringElement, UsaStaggerElement, UsaStickyStackElement, UsaTextRotateElement, UsaTiltElement, UsaToasterElement, UsaToggleElement, UsaTypewriterElement, UsaViewSwitchElement, ViewTransitionOptions };