svg-scroll-draw 2.15.3 → 2.16.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/README.md +19 -16
- package/dist/angular/index.cjs +2 -2
- package/dist/angular/index.d.mts +7 -240
- package/dist/angular/index.d.ts +7 -240
- package/dist/angular/index.mjs +1 -3
- package/dist/aos/index.cjs +2 -2
- package/dist/aos/index.mjs +1 -2
- package/dist/aos/react/index.cjs +2 -2
- package/dist/aos/react/index.d.mts +1 -33
- package/dist/aos/react/index.d.ts +1 -33
- package/dist/aos/react/index.mjs +1 -2
- package/dist/astro/index.cjs +2 -2
- package/dist/astro/index.d.mts +4 -148
- package/dist/astro/index.d.ts +4 -148
- package/dist/astro/index.mjs +1 -3
- package/dist/cdn/aos.global.js +2 -2
- package/dist/cdn/scrollreveal.global.js +2 -2
- package/dist/cdn/svg-scroll-draw.dev.global.js +51 -39
- package/dist/cdn/svg-scroll-draw.global.js +2 -2
- package/dist/cdn/vivus.global.js +1 -1
- package/dist/chunk-4DOJSIEQ.mjs +1 -0
- package/dist/chunk-4MH5SQTH.mjs +1 -0
- package/dist/chunk-4T5R3ZTL.mjs +2 -0
- package/dist/chunk-5PJEKEEP.mjs +1 -0
- package/dist/chunk-AJ22VSHC.mjs +1 -0
- package/dist/chunk-BCV4RAIX.mjs +1 -0
- package/dist/chunk-DM6EDKWH.mjs +1 -0
- package/dist/chunk-E4M2PB7B.mjs +1 -0
- package/dist/chunk-JC5BD4RB.mjs +1 -0
- package/dist/chunk-KBFWDHF4.mjs +1 -0
- package/dist/chunk-KGAJQP2N.mjs +2 -0
- package/dist/chunk-LFSU6LR3.mjs +1 -0
- package/dist/chunk-OJFWQ6CU.mjs +1 -0
- package/dist/chunk-OMI46IXL.mjs +2 -0
- package/dist/chunk-OWMO2S3V.mjs +1 -0
- package/dist/chunk-PEFR3ZB7.mjs +1 -0
- package/dist/chunk-QJ4H2HW3.mjs +1 -0
- package/dist/chunk-SNCRC6BA.mjs +1 -0
- package/dist/chunk-WDIHLRZZ.mjs +3 -0
- package/dist/chunk-WQZKXAXK.mjs +2 -0
- package/dist/chunk-YWKPTYSG.mjs +1 -0
- package/dist/chunk-YZV4Z3EQ.mjs +1 -0
- package/dist/cinematic/index.cjs +1 -1
- package/dist/cinematic/index.mjs +1 -2
- package/dist/devtools/index.mjs +1 -1
- package/dist/engine-6AXEX8CL.d.ts +57 -0
- package/dist/engine-Ci08nM91.d.mts +57 -0
- package/dist/group/index.cjs +2 -2
- package/dist/group/index.d.mts +4 -207
- package/dist/group/index.d.ts +4 -207
- package/dist/group/index.mjs +1 -3
- package/dist/horizontal/index.cjs +1 -1
- package/dist/horizontal/index.d.mts +1 -33
- package/dist/horizontal/index.d.ts +1 -33
- package/dist/horizontal/index.mjs +1 -1
- package/dist/index-BDGQEK6X.d.mts +15 -0
- package/dist/index-BVuNgQSd.d.ts +14 -0
- package/dist/index-CGR7pSOR.d.mts +14 -0
- package/dist/index-DxjUOIbK.d.ts +15 -0
- package/dist/index.cjs +3 -3
- package/dist/index.d.mts +8 -294
- package/dist/index.d.ts +8 -294
- package/dist/index.mjs +1 -4
- package/dist/nuxt/index.cjs +2 -2
- package/dist/nuxt/index.d.mts +7 -507
- package/dist/nuxt/index.d.ts +7 -507
- package/dist/nuxt/index.mjs +1 -3
- package/dist/pin/index.cjs +1 -1
- package/dist/pin/index.mjs +1 -1
- package/dist/progress/index.cjs +1 -1
- package/dist/progress/index.d.mts +1 -33
- package/dist/progress/index.d.ts +1 -33
- package/dist/progress/index.mjs +1 -1
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.d.mts +5 -212
- package/dist/react/index.d.ts +5 -212
- package/dist/react/index.mjs +1 -3
- package/dist/reveal/index.cjs +1 -1
- package/dist/reveal/index.d.mts +1 -5
- package/dist/reveal/index.d.ts +1 -5
- package/dist/reveal/index.mjs +1 -1
- package/dist/scroll-draw-BlJfbTDv.d.ts +5 -0
- package/dist/scroll-draw-CNlq4Z_L.d.mts +5 -0
- package/dist/scrollreveal/index.cjs +2 -2
- package/dist/scrollreveal/index.mjs +1 -2
- package/dist/scrollreveal/react/index.cjs +2 -2
- package/dist/scrollreveal/react/index.d.mts +1 -36
- package/dist/scrollreveal/react/index.d.ts +1 -36
- package/dist/scrollreveal/react/index.mjs +1 -2
- package/dist/snap/index.cjs +1 -1
- package/dist/snap/index.d.mts +1 -1
- package/dist/snap/index.d.ts +1 -1
- package/dist/snap/index.mjs +1 -1
- package/dist/solid/index.cjs +2 -2
- package/dist/solid/index.d.mts +6 -240
- package/dist/solid/index.d.ts +6 -240
- package/dist/solid/index.mjs +1 -3
- package/dist/svelte/index.cjs +2 -2
- package/dist/svelte/index.d.mts +6 -240
- package/dist/svelte/index.d.ts +6 -240
- package/dist/svelte/index.mjs +1 -3
- package/dist/text/index.cjs +1 -1
- package/dist/text/index.d.mts +1 -33
- package/dist/text/index.d.ts +1 -33
- package/dist/text/index.mjs +1 -1
- package/dist/timeline/index.cjs +7 -7
- package/dist/timeline/index.d.mts +1 -29
- package/dist/timeline/index.d.ts +1 -29
- package/dist/timeline/index.mjs +11 -11
- package/dist/types-DHU1zNEw.d.mts +147 -0
- package/dist/types-DHU1zNEw.d.ts +147 -0
- package/dist/video/index.cjs +1 -1
- package/dist/video/index.d.mts +1 -33
- package/dist/video/index.d.ts +1 -33
- package/dist/video/index.mjs +1 -1
- package/dist/vivus/index.cjs +2 -2
- package/dist/vivus/index.mjs +1 -2
- package/dist/vivus/react/index.cjs +2 -1
- package/dist/vivus/react/index.d.mts +1 -99
- package/dist/vivus/react/index.d.ts +1 -99
- package/dist/vivus/react/index.mjs +1 -1
- package/dist/vue/index.cjs +2 -2
- package/dist/vue/index.d.mts +6 -213
- package/dist/vue/index.d.ts +6 -213
- package/dist/vue/index.mjs +1 -3
- package/dist/web-component/index.cjs +2 -2
- package/dist/web-component/index.mjs +1 -3
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,148 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Apply a named preset as the base configuration. User-supplied options
|
|
10
|
-
* always override the preset. Available presets:
|
|
11
|
-
* - `'sketch'` — staggered ease-in draw, pencil feel
|
|
12
|
-
* - `'reveal'` — fade + ease-out, draws once on viewport entry
|
|
13
|
-
* - `'typewriter'` — fast linear draw with stagger
|
|
14
|
-
* - `'cinematic'` — slow ease-in-out with fade, dramatic entrance
|
|
15
|
-
* - `'spring'` — spring easing, bouncy organic feel
|
|
16
|
-
*/
|
|
17
|
-
preset?: PresetName$1;
|
|
18
|
-
selector?: string;
|
|
19
|
-
speed?: number;
|
|
20
|
-
fade?: boolean;
|
|
21
|
-
easing?: EasingName | ((t: number) => number);
|
|
22
|
-
trigger?: TriggerConfig;
|
|
23
|
-
stagger?: number;
|
|
24
|
-
direction?: 'forward' | 'reverse';
|
|
25
|
-
once?: boolean;
|
|
26
|
-
debug?: boolean;
|
|
27
|
-
/** Scroll axis to track. 'y' (default) for vertical, 'x' for horizontal. */
|
|
28
|
-
axis?: 'x' | 'y';
|
|
29
|
-
/** CSS selector or Element for a custom scroll container (default: window). */
|
|
30
|
-
scrollContainer?: string | Element;
|
|
31
|
-
/** Automatically reverse the animation when the user scrolls back up. */
|
|
32
|
-
autoReverse?: boolean;
|
|
33
|
-
/** Delay in milliseconds before the engine starts observing. */
|
|
34
|
-
delay?: number;
|
|
35
|
-
/** Animate stroke color. Single string = static override. Tuple = interpolate from → to. */
|
|
36
|
-
strokeColor?: string | [string, string];
|
|
37
|
-
/** Animate stroke width. Single number = static override. Tuple = interpolate from → to. */
|
|
38
|
-
strokeWidth?: number | [number, number];
|
|
39
|
-
/** Animate fill opacity. Single number = static override. Tuple [from, to] = interpolate as the path draws. Use [0, 1] to flood fill in sync with the stroke draw. */
|
|
40
|
-
fillOpacity?: number | [number, number];
|
|
41
|
-
/**
|
|
42
|
-
* Reveal the container using CSS clip-path instead of stroke-dashoffset.
|
|
43
|
-
* Works on any content — SVG, images, text, divs.
|
|
44
|
-
*
|
|
45
|
-
* Pass a direction string to control which edge the reveal starts from,
|
|
46
|
-
* or `true` as shorthand for `'left'`.
|
|
47
|
-
*
|
|
48
|
-
* Values: `'left' | 'right' | 'top' | 'bottom' | 'center'`
|
|
49
|
-
*/
|
|
50
|
-
clip?: boolean | 'left' | 'right' | 'top' | 'bottom' | 'center';
|
|
51
|
-
/** Fire callbacks at specific progress thresholds (0–1). Resets on replay(). */
|
|
52
|
-
waypoints?: Record<number, () => void>;
|
|
53
|
-
/** Scale animation speed by scroll velocity — faster scrolling = faster draw. Pass a number to control sensitivity (default 1). */
|
|
54
|
-
velocityScale?: boolean | number;
|
|
55
|
-
/** IntersectionObserver threshold (0–1). Default 0. */
|
|
56
|
-
threshold?: number;
|
|
57
|
-
/** IntersectionObserver rootMargin. Default "0px". */
|
|
58
|
-
rootMargin?: string;
|
|
59
|
-
/** Repeat the animation N times after completion. Use 'infinite' to loop forever. */
|
|
60
|
-
repeat?: number | 'infinite';
|
|
61
|
-
/** Milliseconds to wait between repeats. Default 0. */
|
|
62
|
-
repeatDelay?: number;
|
|
63
|
-
/**
|
|
64
|
-
* Target path `d` attribute to morph toward as the animation progresses.
|
|
65
|
-
* Paths must have compatible command structures (same number of numeric tokens).
|
|
66
|
-
*
|
|
67
|
-
* Only applies to `<path>` elements — silently no-ops on `<rect>`, `<circle>`,
|
|
68
|
-
* `<line>`, and other SVG shape elements.
|
|
69
|
-
*/
|
|
70
|
-
morphTo?: string;
|
|
71
|
-
onProgress?: (alpha: number) => void;
|
|
72
|
-
onStart?: () => void;
|
|
73
|
-
onComplete?: () => void;
|
|
74
|
-
/** Fires when scroll position enters the trigger zone (scrolling forward). */
|
|
75
|
-
onEnter?: () => void;
|
|
76
|
-
/** Fires when scroll position exits the trigger zone at the end (scrolling forward). */
|
|
77
|
-
onLeave?: () => void;
|
|
78
|
-
/** Fires when scroll position re-enters the trigger zone from the end (scrolling back). */
|
|
79
|
-
onEnterBack?: () => void;
|
|
80
|
-
/** Fires when scroll position exits the trigger zone at the start (scrolling back). */
|
|
81
|
-
onLeaveBack?: () => void;
|
|
82
|
-
/**
|
|
83
|
-
* Trigger the animation when the element enters the viewport instead of
|
|
84
|
-
* tying it to scroll position. The draw runs over `duration` milliseconds,
|
|
85
|
-
* replaying each time the element re-enters the viewport (use `once: true`
|
|
86
|
-
* to play only the first time).
|
|
87
|
-
*
|
|
88
|
-
* All visual options work in autoplay mode — `easing`, `stagger`, `fade`,
|
|
89
|
-
* `strokeColor`, `strokeWidth`, `fillOpacity`, `clip`, `morphTo`, `waypoints`,
|
|
90
|
-
* `repeat`, `repeatDelay`, `onStart`, `onComplete`, `onProgress`, etc.
|
|
91
|
-
*
|
|
92
|
-
* The full instance API (`pause`, `resume`, `seek`, `replay`, `getProgress`)
|
|
93
|
-
* also works — `seek(0.5)` pauses at 50% of the duration.
|
|
94
|
-
*/
|
|
95
|
-
autoplay?: boolean;
|
|
96
|
-
/**
|
|
97
|
-
* Duration of the autoplay animation in milliseconds. Only used when
|
|
98
|
-
* `autoplay: true`. Default `1000`.
|
|
99
|
-
*/
|
|
100
|
-
duration?: number;
|
|
101
|
-
/**
|
|
102
|
-
* Use the browser's native CSS scroll-driven animation
|
|
103
|
-
* (`animation-timeline: view()`) when the configuration is simple enough and
|
|
104
|
-
* the browser supports it. The browser drives the draw from the scroll
|
|
105
|
-
* position — zero per-frame JavaScript, zero scroll/resize listeners. (It
|
|
106
|
-
* still repaints on the main thread: browsers don't composite
|
|
107
|
-
* `stroke-dashoffset`.)
|
|
108
|
-
*
|
|
109
|
-
* Falls back to the JS engine automatically when unsupported or when the
|
|
110
|
-
* config uses a feature native CSS can't express (callbacks, stagger, morph,
|
|
111
|
-
* velocity scaling, custom triggers, `once`, custom easing functions, etc.).
|
|
112
|
-
*
|
|
113
|
-
* - `undefined` / `true` (default): use native when eligible.
|
|
114
|
-
* - `false`: always use the JS engine.
|
|
115
|
-
*/
|
|
116
|
-
native?: boolean;
|
|
117
|
-
}
|
|
118
|
-
interface ScrollDrawInstance {
|
|
119
|
-
destroy: () => void;
|
|
120
|
-
/** Reset and replay the animation from the beginning. */
|
|
121
|
-
replay: () => void;
|
|
122
|
-
/** Pause the animation at the current progress. */
|
|
123
|
-
pause: () => void;
|
|
124
|
-
/** Resume a paused animation. */
|
|
125
|
-
resume: () => void;
|
|
126
|
-
/** Jump to a specific progress value (0–1) and pause. */
|
|
127
|
-
seek: (progress: number) => void;
|
|
128
|
-
/** Returns current draw progress (0–1). */
|
|
129
|
-
getProgress: () => number;
|
|
130
|
-
/**
|
|
131
|
-
* Re-measure after a layout change: path lengths, and the scroll trigger window.
|
|
132
|
-
*
|
|
133
|
-
* The engine already re-measures on `resize`, on `orientationchange`, and via a
|
|
134
|
-
* `ResizeObserver` on the document element — but none of those fire for a layout
|
|
135
|
-
* change that leaves the document height alone, such as a tab switching, a
|
|
136
|
-
* sibling collapsing, or a font swapping inside a fixed-height box. Call this
|
|
137
|
-
* after one of those.
|
|
138
|
-
*
|
|
139
|
-
* Optional on this shared type because several instances here are fan-outs over
|
|
140
|
-
* other instances or SSR no-op stubs. `scrollDraw`, `scrollPin`,
|
|
141
|
-
* `scrollHorizontal`, `scrollDrawTimeline` and the group APIs all provide it;
|
|
142
|
-
* use `instance.refresh?.()` if you hold an instance of unknown origin.
|
|
143
|
-
*/
|
|
144
|
-
refresh?: () => void;
|
|
145
|
-
}
|
|
1
|
+
import { a as ScrollDrawOptions } from './types-DHU1zNEw.mjs';
|
|
2
|
+
export { P as PresetName, S as ScrollDrawInstance } from './types-DHU1zNEw.mjs';
|
|
3
|
+
export { s as scrollDraw } from './scroll-draw-CNlq4Z_L.mjs';
|
|
4
|
+
export { S as ScrollParallaxOptions, s as scrollAnimate, a as scrollParallax } from './index-CGR7pSOR.mjs';
|
|
5
|
+
export { S as ScrollCounterOptions, s as scrollCounter } from './index-BDGQEK6X.mjs';
|
|
6
|
+
export { Cinematic, CinematicInstance, CinematicOptions, DrawAnimation, FadeAnimation, Story, StoryAnimation, StoryEasing, StoryScene } from './cinematic/index.mjs';
|
|
7
|
+
export { S as ScrollAnimateOptions } from './engine-Ci08nM91.mjs';
|
|
146
8
|
|
|
147
9
|
type PresetName = 'sketch' | 'reveal' | 'typewriter' | 'cinematic' | 'spring';
|
|
148
10
|
/**
|
|
@@ -197,152 +59,4 @@ declare function createElastic({ amplitude, period, }?: {
|
|
|
197
59
|
period?: number;
|
|
198
60
|
}): (t: number) => number;
|
|
199
61
|
|
|
200
|
-
|
|
201
|
-
props: Record<string, string | number | [string | number, string | number]>;
|
|
202
|
-
trigger?: TriggerConfig;
|
|
203
|
-
easing?: EasingName | ((t: number) => number);
|
|
204
|
-
speed?: number;
|
|
205
|
-
once?: boolean;
|
|
206
|
-
axis?: 'x' | 'y';
|
|
207
|
-
scrollContainer?: string | Element;
|
|
208
|
-
native?: boolean;
|
|
209
|
-
/**
|
|
210
|
-
* Scale animation speed by scroll velocity — faster scrolling = faster animation.
|
|
211
|
-
* Pass `true` for default sensitivity (1) or a number to control it.
|
|
212
|
-
* Higher values = more dramatic speed-up. Default sensitivity: 1.
|
|
213
|
-
*/
|
|
214
|
-
velocityScale?: boolean | number;
|
|
215
|
-
/**
|
|
216
|
-
* Honour `prefers-reduced-motion: reduce` by applying the final state and not
|
|
217
|
-
* animating. Default: `true`.
|
|
218
|
-
*
|
|
219
|
-
* Set to `false` only when the movement is *scroll-linked scrubbing* rather
|
|
220
|
-
* than autonomous motion — it advances solely as the user scrolls, 1:1 with
|
|
221
|
-
* their input, so it is direct manipulation rather than something that plays at
|
|
222
|
-
* them. `scrollHorizontal` sets this, because jumping to the final state there
|
|
223
|
-
* would leave every panel but the last unreachable inside the sticky
|
|
224
|
-
* `overflow: hidden` container.
|
|
225
|
-
*/
|
|
226
|
-
respectReducedMotion?: boolean;
|
|
227
|
-
/**
|
|
228
|
-
* Element whose geometry defines the trigger window, when that is not the
|
|
229
|
-
* element being animated. Defaults to the animated element.
|
|
230
|
-
*
|
|
231
|
-
* Needed whenever the animated element cannot supply the scroll length itself —
|
|
232
|
-
* the case that matters is a `position: sticky` stage, where the pinned element
|
|
233
|
-
* is exactly one viewport tall and all of the scroll room belongs to its
|
|
234
|
-
* container. Resolving `top top` → `bottom bottom` against the pinned element
|
|
235
|
-
* there yields tStart === tEnd, a zero-length window, and no movement at all.
|
|
236
|
-
*
|
|
237
|
-
* Setting this disables the native CSS fast path: `animation-timeline: view()`
|
|
238
|
-
* always measures the element the animation is attached to, so it cannot express
|
|
239
|
-
* a separate subject.
|
|
240
|
-
*/
|
|
241
|
-
triggerElement?: Element;
|
|
242
|
-
onProgress?: (alpha: number) => void;
|
|
243
|
-
onComplete?: () => void;
|
|
244
|
-
/** Fires when scroll enters the trigger zone (scrolling forward). */
|
|
245
|
-
onEnter?: () => void;
|
|
246
|
-
/** Fires when scroll exits the trigger zone at the end (scrolling forward). */
|
|
247
|
-
onLeave?: () => void;
|
|
248
|
-
/** Fires when scroll re-enters the trigger zone from the end (scrolling back). */
|
|
249
|
-
onEnterBack?: () => void;
|
|
250
|
-
/** Fires when scroll exits the trigger zone at the start (scrolling back). */
|
|
251
|
-
onLeaveBack?: () => void;
|
|
252
|
-
}
|
|
253
|
-
interface ScrollParallaxOptions {
|
|
254
|
-
speed?: number;
|
|
255
|
-
axis?: 'x' | 'y';
|
|
256
|
-
easing?: EasingName | ((t: number) => number);
|
|
257
|
-
trigger?: TriggerConfig;
|
|
258
|
-
onProgress?: (alpha: number) => void;
|
|
259
|
-
}
|
|
260
|
-
declare function scrollAnimate(target: string | Element, options: ScrollAnimateOptions): ScrollDrawInstance;
|
|
261
|
-
declare function scrollParallax(target: string | Element, options?: ScrollParallaxOptions): ScrollDrawInstance;
|
|
262
|
-
|
|
263
|
-
interface ScrollCounterOptions {
|
|
264
|
-
from?: number;
|
|
265
|
-
to: number;
|
|
266
|
-
format?: (value: number) => string;
|
|
267
|
-
easing?: EasingName | ((t: number) => number);
|
|
268
|
-
trigger?: TriggerConfig;
|
|
269
|
-
once?: boolean;
|
|
270
|
-
decimals?: number;
|
|
271
|
-
onComplete?: () => void;
|
|
272
|
-
}
|
|
273
|
-
declare function scrollCounter(target: string | Element, options: ScrollCounterOptions): ScrollDrawInstance;
|
|
274
|
-
|
|
275
|
-
type StoryEasing = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring' | 'bounce' | 'elastic';
|
|
276
|
-
/** A traced path that strokes itself on across a scroll range. */
|
|
277
|
-
interface DrawAnimation {
|
|
278
|
-
type: 'draw';
|
|
279
|
-
/** DOM id the runtime binds to (with leading '#'), e.g. "#path-3". */
|
|
280
|
-
target: string;
|
|
281
|
-
/** SVG path data, in canvas coordinates. */
|
|
282
|
-
d: string;
|
|
283
|
-
/** Pre-measured total path length (px). */
|
|
284
|
-
length: number;
|
|
285
|
-
/** Scroll progress where the draw begins, e.g. "20%". */
|
|
286
|
-
start: string;
|
|
287
|
-
/** Scroll progress where the draw completes, e.g. "50%". */
|
|
288
|
-
end: string;
|
|
289
|
-
stroke: string;
|
|
290
|
-
strokeWidth: number;
|
|
291
|
-
easing: StoryEasing;
|
|
292
|
-
}
|
|
293
|
-
/** Any layer fading opacity across a scroll range. */
|
|
294
|
-
interface FadeAnimation {
|
|
295
|
-
type: 'fade';
|
|
296
|
-
target: string;
|
|
297
|
-
start: string;
|
|
298
|
-
end: string;
|
|
299
|
-
from: number;
|
|
300
|
-
to: number;
|
|
301
|
-
}
|
|
302
|
-
type StoryAnimation = DrawAnimation | FadeAnimation;
|
|
303
|
-
interface StoryScene {
|
|
304
|
-
id: string;
|
|
305
|
-
/** Optional background layer (a product photo) as a data URL or remote URL. */
|
|
306
|
-
background?: string;
|
|
307
|
-
animations: StoryAnimation[];
|
|
308
|
-
}
|
|
309
|
-
interface Story {
|
|
310
|
-
version: 1;
|
|
311
|
-
/** Total scroll height of the experience, e.g. "400vh". */
|
|
312
|
-
totalHeight: string;
|
|
313
|
-
/** The authoring viewBox the coordinates are expressed in. */
|
|
314
|
-
canvas: {
|
|
315
|
-
width: number;
|
|
316
|
-
height: number;
|
|
317
|
-
};
|
|
318
|
-
scenes: StoryScene[];
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
interface CinematicOptions {
|
|
322
|
-
/** Mount point — a selector or element. Becomes the scroll wrapper. */
|
|
323
|
-
wrapper: string | HTMLElement;
|
|
324
|
-
}
|
|
325
|
-
interface CinematicInstance {
|
|
326
|
-
/** Stop the scroll loop and detach observers (built DOM is left in place). */
|
|
327
|
-
destroy: () => void;
|
|
328
|
-
/** Current global scroll progress through the story (0–1). */
|
|
329
|
-
getProgress: () => number;
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* The viral loader. Reads a Cinematic Story (authored in the Studio) and wires
|
|
333
|
-
* a scroll-scrubbed timeline: paths stroke themselves on and layers fade in as
|
|
334
|
-
* the user scrolls, all driven off the wrapper's scroll progress.
|
|
335
|
-
*
|
|
336
|
-
* import { Cinematic } from "svg-scroll-draw";
|
|
337
|
-
* import story from "./story.json";
|
|
338
|
-
* new Cinematic({ wrapper: "#app" }).loadStory(story);
|
|
339
|
-
*/
|
|
340
|
-
declare class Cinematic {
|
|
341
|
-
private mount;
|
|
342
|
-
constructor(options: CinematicOptions);
|
|
343
|
-
loadStory(story: Story): CinematicInstance;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
declare function scrollDraw(target: string | Element, options?: ScrollDrawOptions): ScrollDrawInstance;
|
|
347
|
-
|
|
348
|
-
export { Cinematic, type CinematicInstance, type CinematicOptions, type DrawAnimation, type FadeAnimation, PRESETS, type PresetName$1 as PresetName, type ScrollAnimateOptions, type ScrollCounterOptions, type ScrollDrawInstance, type ScrollDrawOptions, type ScrollParallaxOptions, type Story, type StoryAnimation, type StoryEasing, type StoryScene, createBounce, createElastic, createSpring, scrollAnimate, scrollCounter, scrollDraw, scrollParallax };
|
|
62
|
+
export { PRESETS, ScrollDrawOptions, createBounce, createElastic, createSpring };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,148 +1,10 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
7
|
-
|
|
8
|
-
/**
|
|
9
|
-
* Apply a named preset as the base configuration. User-supplied options
|
|
10
|
-
* always override the preset. Available presets:
|
|
11
|
-
* - `'sketch'` — staggered ease-in draw, pencil feel
|
|
12
|
-
* - `'reveal'` — fade + ease-out, draws once on viewport entry
|
|
13
|
-
* - `'typewriter'` — fast linear draw with stagger
|
|
14
|
-
* - `'cinematic'` — slow ease-in-out with fade, dramatic entrance
|
|
15
|
-
* - `'spring'` — spring easing, bouncy organic feel
|
|
16
|
-
*/
|
|
17
|
-
preset?: PresetName$1;
|
|
18
|
-
selector?: string;
|
|
19
|
-
speed?: number;
|
|
20
|
-
fade?: boolean;
|
|
21
|
-
easing?: EasingName | ((t: number) => number);
|
|
22
|
-
trigger?: TriggerConfig;
|
|
23
|
-
stagger?: number;
|
|
24
|
-
direction?: 'forward' | 'reverse';
|
|
25
|
-
once?: boolean;
|
|
26
|
-
debug?: boolean;
|
|
27
|
-
/** Scroll axis to track. 'y' (default) for vertical, 'x' for horizontal. */
|
|
28
|
-
axis?: 'x' | 'y';
|
|
29
|
-
/** CSS selector or Element for a custom scroll container (default: window). */
|
|
30
|
-
scrollContainer?: string | Element;
|
|
31
|
-
/** Automatically reverse the animation when the user scrolls back up. */
|
|
32
|
-
autoReverse?: boolean;
|
|
33
|
-
/** Delay in milliseconds before the engine starts observing. */
|
|
34
|
-
delay?: number;
|
|
35
|
-
/** Animate stroke color. Single string = static override. Tuple = interpolate from → to. */
|
|
36
|
-
strokeColor?: string | [string, string];
|
|
37
|
-
/** Animate stroke width. Single number = static override. Tuple = interpolate from → to. */
|
|
38
|
-
strokeWidth?: number | [number, number];
|
|
39
|
-
/** Animate fill opacity. Single number = static override. Tuple [from, to] = interpolate as the path draws. Use [0, 1] to flood fill in sync with the stroke draw. */
|
|
40
|
-
fillOpacity?: number | [number, number];
|
|
41
|
-
/**
|
|
42
|
-
* Reveal the container using CSS clip-path instead of stroke-dashoffset.
|
|
43
|
-
* Works on any content — SVG, images, text, divs.
|
|
44
|
-
*
|
|
45
|
-
* Pass a direction string to control which edge the reveal starts from,
|
|
46
|
-
* or `true` as shorthand for `'left'`.
|
|
47
|
-
*
|
|
48
|
-
* Values: `'left' | 'right' | 'top' | 'bottom' | 'center'`
|
|
49
|
-
*/
|
|
50
|
-
clip?: boolean | 'left' | 'right' | 'top' | 'bottom' | 'center';
|
|
51
|
-
/** Fire callbacks at specific progress thresholds (0–1). Resets on replay(). */
|
|
52
|
-
waypoints?: Record<number, () => void>;
|
|
53
|
-
/** Scale animation speed by scroll velocity — faster scrolling = faster draw. Pass a number to control sensitivity (default 1). */
|
|
54
|
-
velocityScale?: boolean | number;
|
|
55
|
-
/** IntersectionObserver threshold (0–1). Default 0. */
|
|
56
|
-
threshold?: number;
|
|
57
|
-
/** IntersectionObserver rootMargin. Default "0px". */
|
|
58
|
-
rootMargin?: string;
|
|
59
|
-
/** Repeat the animation N times after completion. Use 'infinite' to loop forever. */
|
|
60
|
-
repeat?: number | 'infinite';
|
|
61
|
-
/** Milliseconds to wait between repeats. Default 0. */
|
|
62
|
-
repeatDelay?: number;
|
|
63
|
-
/**
|
|
64
|
-
* Target path `d` attribute to morph toward as the animation progresses.
|
|
65
|
-
* Paths must have compatible command structures (same number of numeric tokens).
|
|
66
|
-
*
|
|
67
|
-
* Only applies to `<path>` elements — silently no-ops on `<rect>`, `<circle>`,
|
|
68
|
-
* `<line>`, and other SVG shape elements.
|
|
69
|
-
*/
|
|
70
|
-
morphTo?: string;
|
|
71
|
-
onProgress?: (alpha: number) => void;
|
|
72
|
-
onStart?: () => void;
|
|
73
|
-
onComplete?: () => void;
|
|
74
|
-
/** Fires when scroll position enters the trigger zone (scrolling forward). */
|
|
75
|
-
onEnter?: () => void;
|
|
76
|
-
/** Fires when scroll position exits the trigger zone at the end (scrolling forward). */
|
|
77
|
-
onLeave?: () => void;
|
|
78
|
-
/** Fires when scroll position re-enters the trigger zone from the end (scrolling back). */
|
|
79
|
-
onEnterBack?: () => void;
|
|
80
|
-
/** Fires when scroll position exits the trigger zone at the start (scrolling back). */
|
|
81
|
-
onLeaveBack?: () => void;
|
|
82
|
-
/**
|
|
83
|
-
* Trigger the animation when the element enters the viewport instead of
|
|
84
|
-
* tying it to scroll position. The draw runs over `duration` milliseconds,
|
|
85
|
-
* replaying each time the element re-enters the viewport (use `once: true`
|
|
86
|
-
* to play only the first time).
|
|
87
|
-
*
|
|
88
|
-
* All visual options work in autoplay mode — `easing`, `stagger`, `fade`,
|
|
89
|
-
* `strokeColor`, `strokeWidth`, `fillOpacity`, `clip`, `morphTo`, `waypoints`,
|
|
90
|
-
* `repeat`, `repeatDelay`, `onStart`, `onComplete`, `onProgress`, etc.
|
|
91
|
-
*
|
|
92
|
-
* The full instance API (`pause`, `resume`, `seek`, `replay`, `getProgress`)
|
|
93
|
-
* also works — `seek(0.5)` pauses at 50% of the duration.
|
|
94
|
-
*/
|
|
95
|
-
autoplay?: boolean;
|
|
96
|
-
/**
|
|
97
|
-
* Duration of the autoplay animation in milliseconds. Only used when
|
|
98
|
-
* `autoplay: true`. Default `1000`.
|
|
99
|
-
*/
|
|
100
|
-
duration?: number;
|
|
101
|
-
/**
|
|
102
|
-
* Use the browser's native CSS scroll-driven animation
|
|
103
|
-
* (`animation-timeline: view()`) when the configuration is simple enough and
|
|
104
|
-
* the browser supports it. The browser drives the draw from the scroll
|
|
105
|
-
* position — zero per-frame JavaScript, zero scroll/resize listeners. (It
|
|
106
|
-
* still repaints on the main thread: browsers don't composite
|
|
107
|
-
* `stroke-dashoffset`.)
|
|
108
|
-
*
|
|
109
|
-
* Falls back to the JS engine automatically when unsupported or when the
|
|
110
|
-
* config uses a feature native CSS can't express (callbacks, stagger, morph,
|
|
111
|
-
* velocity scaling, custom triggers, `once`, custom easing functions, etc.).
|
|
112
|
-
*
|
|
113
|
-
* - `undefined` / `true` (default): use native when eligible.
|
|
114
|
-
* - `false`: always use the JS engine.
|
|
115
|
-
*/
|
|
116
|
-
native?: boolean;
|
|
117
|
-
}
|
|
118
|
-
interface ScrollDrawInstance {
|
|
119
|
-
destroy: () => void;
|
|
120
|
-
/** Reset and replay the animation from the beginning. */
|
|
121
|
-
replay: () => void;
|
|
122
|
-
/** Pause the animation at the current progress. */
|
|
123
|
-
pause: () => void;
|
|
124
|
-
/** Resume a paused animation. */
|
|
125
|
-
resume: () => void;
|
|
126
|
-
/** Jump to a specific progress value (0–1) and pause. */
|
|
127
|
-
seek: (progress: number) => void;
|
|
128
|
-
/** Returns current draw progress (0–1). */
|
|
129
|
-
getProgress: () => number;
|
|
130
|
-
/**
|
|
131
|
-
* Re-measure after a layout change: path lengths, and the scroll trigger window.
|
|
132
|
-
*
|
|
133
|
-
* The engine already re-measures on `resize`, on `orientationchange`, and via a
|
|
134
|
-
* `ResizeObserver` on the document element — but none of those fire for a layout
|
|
135
|
-
* change that leaves the document height alone, such as a tab switching, a
|
|
136
|
-
* sibling collapsing, or a font swapping inside a fixed-height box. Call this
|
|
137
|
-
* after one of those.
|
|
138
|
-
*
|
|
139
|
-
* Optional on this shared type because several instances here are fan-outs over
|
|
140
|
-
* other instances or SSR no-op stubs. `scrollDraw`, `scrollPin`,
|
|
141
|
-
* `scrollHorizontal`, `scrollDrawTimeline` and the group APIs all provide it;
|
|
142
|
-
* use `instance.refresh?.()` if you hold an instance of unknown origin.
|
|
143
|
-
*/
|
|
144
|
-
refresh?: () => void;
|
|
145
|
-
}
|
|
1
|
+
import { a as ScrollDrawOptions } from './types-DHU1zNEw.js';
|
|
2
|
+
export { P as PresetName, S as ScrollDrawInstance } from './types-DHU1zNEw.js';
|
|
3
|
+
export { s as scrollDraw } from './scroll-draw-BlJfbTDv.js';
|
|
4
|
+
export { S as ScrollParallaxOptions, s as scrollAnimate, a as scrollParallax } from './index-BVuNgQSd.js';
|
|
5
|
+
export { S as ScrollCounterOptions, s as scrollCounter } from './index-DxjUOIbK.js';
|
|
6
|
+
export { Cinematic, CinematicInstance, CinematicOptions, DrawAnimation, FadeAnimation, Story, StoryAnimation, StoryEasing, StoryScene } from './cinematic/index.js';
|
|
7
|
+
export { S as ScrollAnimateOptions } from './engine-6AXEX8CL.js';
|
|
146
8
|
|
|
147
9
|
type PresetName = 'sketch' | 'reveal' | 'typewriter' | 'cinematic' | 'spring';
|
|
148
10
|
/**
|
|
@@ -197,152 +59,4 @@ declare function createElastic({ amplitude, period, }?: {
|
|
|
197
59
|
period?: number;
|
|
198
60
|
}): (t: number) => number;
|
|
199
61
|
|
|
200
|
-
|
|
201
|
-
props: Record<string, string | number | [string | number, string | number]>;
|
|
202
|
-
trigger?: TriggerConfig;
|
|
203
|
-
easing?: EasingName | ((t: number) => number);
|
|
204
|
-
speed?: number;
|
|
205
|
-
once?: boolean;
|
|
206
|
-
axis?: 'x' | 'y';
|
|
207
|
-
scrollContainer?: string | Element;
|
|
208
|
-
native?: boolean;
|
|
209
|
-
/**
|
|
210
|
-
* Scale animation speed by scroll velocity — faster scrolling = faster animation.
|
|
211
|
-
* Pass `true` for default sensitivity (1) or a number to control it.
|
|
212
|
-
* Higher values = more dramatic speed-up. Default sensitivity: 1.
|
|
213
|
-
*/
|
|
214
|
-
velocityScale?: boolean | number;
|
|
215
|
-
/**
|
|
216
|
-
* Honour `prefers-reduced-motion: reduce` by applying the final state and not
|
|
217
|
-
* animating. Default: `true`.
|
|
218
|
-
*
|
|
219
|
-
* Set to `false` only when the movement is *scroll-linked scrubbing* rather
|
|
220
|
-
* than autonomous motion — it advances solely as the user scrolls, 1:1 with
|
|
221
|
-
* their input, so it is direct manipulation rather than something that plays at
|
|
222
|
-
* them. `scrollHorizontal` sets this, because jumping to the final state there
|
|
223
|
-
* would leave every panel but the last unreachable inside the sticky
|
|
224
|
-
* `overflow: hidden` container.
|
|
225
|
-
*/
|
|
226
|
-
respectReducedMotion?: boolean;
|
|
227
|
-
/**
|
|
228
|
-
* Element whose geometry defines the trigger window, when that is not the
|
|
229
|
-
* element being animated. Defaults to the animated element.
|
|
230
|
-
*
|
|
231
|
-
* Needed whenever the animated element cannot supply the scroll length itself —
|
|
232
|
-
* the case that matters is a `position: sticky` stage, where the pinned element
|
|
233
|
-
* is exactly one viewport tall and all of the scroll room belongs to its
|
|
234
|
-
* container. Resolving `top top` → `bottom bottom` against the pinned element
|
|
235
|
-
* there yields tStart === tEnd, a zero-length window, and no movement at all.
|
|
236
|
-
*
|
|
237
|
-
* Setting this disables the native CSS fast path: `animation-timeline: view()`
|
|
238
|
-
* always measures the element the animation is attached to, so it cannot express
|
|
239
|
-
* a separate subject.
|
|
240
|
-
*/
|
|
241
|
-
triggerElement?: Element;
|
|
242
|
-
onProgress?: (alpha: number) => void;
|
|
243
|
-
onComplete?: () => void;
|
|
244
|
-
/** Fires when scroll enters the trigger zone (scrolling forward). */
|
|
245
|
-
onEnter?: () => void;
|
|
246
|
-
/** Fires when scroll exits the trigger zone at the end (scrolling forward). */
|
|
247
|
-
onLeave?: () => void;
|
|
248
|
-
/** Fires when scroll re-enters the trigger zone from the end (scrolling back). */
|
|
249
|
-
onEnterBack?: () => void;
|
|
250
|
-
/** Fires when scroll exits the trigger zone at the start (scrolling back). */
|
|
251
|
-
onLeaveBack?: () => void;
|
|
252
|
-
}
|
|
253
|
-
interface ScrollParallaxOptions {
|
|
254
|
-
speed?: number;
|
|
255
|
-
axis?: 'x' | 'y';
|
|
256
|
-
easing?: EasingName | ((t: number) => number);
|
|
257
|
-
trigger?: TriggerConfig;
|
|
258
|
-
onProgress?: (alpha: number) => void;
|
|
259
|
-
}
|
|
260
|
-
declare function scrollAnimate(target: string | Element, options: ScrollAnimateOptions): ScrollDrawInstance;
|
|
261
|
-
declare function scrollParallax(target: string | Element, options?: ScrollParallaxOptions): ScrollDrawInstance;
|
|
262
|
-
|
|
263
|
-
interface ScrollCounterOptions {
|
|
264
|
-
from?: number;
|
|
265
|
-
to: number;
|
|
266
|
-
format?: (value: number) => string;
|
|
267
|
-
easing?: EasingName | ((t: number) => number);
|
|
268
|
-
trigger?: TriggerConfig;
|
|
269
|
-
once?: boolean;
|
|
270
|
-
decimals?: number;
|
|
271
|
-
onComplete?: () => void;
|
|
272
|
-
}
|
|
273
|
-
declare function scrollCounter(target: string | Element, options: ScrollCounterOptions): ScrollDrawInstance;
|
|
274
|
-
|
|
275
|
-
type StoryEasing = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring' | 'bounce' | 'elastic';
|
|
276
|
-
/** A traced path that strokes itself on across a scroll range. */
|
|
277
|
-
interface DrawAnimation {
|
|
278
|
-
type: 'draw';
|
|
279
|
-
/** DOM id the runtime binds to (with leading '#'), e.g. "#path-3". */
|
|
280
|
-
target: string;
|
|
281
|
-
/** SVG path data, in canvas coordinates. */
|
|
282
|
-
d: string;
|
|
283
|
-
/** Pre-measured total path length (px). */
|
|
284
|
-
length: number;
|
|
285
|
-
/** Scroll progress where the draw begins, e.g. "20%". */
|
|
286
|
-
start: string;
|
|
287
|
-
/** Scroll progress where the draw completes, e.g. "50%". */
|
|
288
|
-
end: string;
|
|
289
|
-
stroke: string;
|
|
290
|
-
strokeWidth: number;
|
|
291
|
-
easing: StoryEasing;
|
|
292
|
-
}
|
|
293
|
-
/** Any layer fading opacity across a scroll range. */
|
|
294
|
-
interface FadeAnimation {
|
|
295
|
-
type: 'fade';
|
|
296
|
-
target: string;
|
|
297
|
-
start: string;
|
|
298
|
-
end: string;
|
|
299
|
-
from: number;
|
|
300
|
-
to: number;
|
|
301
|
-
}
|
|
302
|
-
type StoryAnimation = DrawAnimation | FadeAnimation;
|
|
303
|
-
interface StoryScene {
|
|
304
|
-
id: string;
|
|
305
|
-
/** Optional background layer (a product photo) as a data URL or remote URL. */
|
|
306
|
-
background?: string;
|
|
307
|
-
animations: StoryAnimation[];
|
|
308
|
-
}
|
|
309
|
-
interface Story {
|
|
310
|
-
version: 1;
|
|
311
|
-
/** Total scroll height of the experience, e.g. "400vh". */
|
|
312
|
-
totalHeight: string;
|
|
313
|
-
/** The authoring viewBox the coordinates are expressed in. */
|
|
314
|
-
canvas: {
|
|
315
|
-
width: number;
|
|
316
|
-
height: number;
|
|
317
|
-
};
|
|
318
|
-
scenes: StoryScene[];
|
|
319
|
-
}
|
|
320
|
-
|
|
321
|
-
interface CinematicOptions {
|
|
322
|
-
/** Mount point — a selector or element. Becomes the scroll wrapper. */
|
|
323
|
-
wrapper: string | HTMLElement;
|
|
324
|
-
}
|
|
325
|
-
interface CinematicInstance {
|
|
326
|
-
/** Stop the scroll loop and detach observers (built DOM is left in place). */
|
|
327
|
-
destroy: () => void;
|
|
328
|
-
/** Current global scroll progress through the story (0–1). */
|
|
329
|
-
getProgress: () => number;
|
|
330
|
-
}
|
|
331
|
-
/**
|
|
332
|
-
* The viral loader. Reads a Cinematic Story (authored in the Studio) and wires
|
|
333
|
-
* a scroll-scrubbed timeline: paths stroke themselves on and layers fade in as
|
|
334
|
-
* the user scrolls, all driven off the wrapper's scroll progress.
|
|
335
|
-
*
|
|
336
|
-
* import { Cinematic } from "svg-scroll-draw";
|
|
337
|
-
* import story from "./story.json";
|
|
338
|
-
* new Cinematic({ wrapper: "#app" }).loadStory(story);
|
|
339
|
-
*/
|
|
340
|
-
declare class Cinematic {
|
|
341
|
-
private mount;
|
|
342
|
-
constructor(options: CinematicOptions);
|
|
343
|
-
loadStory(story: Story): CinematicInstance;
|
|
344
|
-
}
|
|
345
|
-
|
|
346
|
-
declare function scrollDraw(target: string | Element, options?: ScrollDrawOptions): ScrollDrawInstance;
|
|
347
|
-
|
|
348
|
-
export { Cinematic, type CinematicInstance, type CinematicOptions, type DrawAnimation, type FadeAnimation, PRESETS, type PresetName$1 as PresetName, type ScrollAnimateOptions, type ScrollCounterOptions, type ScrollDrawInstance, type ScrollDrawOptions, type ScrollParallaxOptions, type Story, type StoryAnimation, type StoryEasing, type StoryScene, createBounce, createElastic, createSpring, scrollAnimate, scrollCounter, scrollDraw, scrollParallax };
|
|
62
|
+
export { PRESETS, ScrollDrawOptions, createBounce, createElastic, createSpring };
|