svg-scroll-draw 2.2.0 → 2.6.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.
@@ -108,6 +108,59 @@ interface ScrollDrawOptions {
108
108
  native?: boolean;
109
109
  }
110
110
 
111
+ interface ScrollAnimateOptions {
112
+ props: Record<string, string | number | [string | number, string | number]>;
113
+ trigger?: TriggerConfig;
114
+ easing?: EasingName | ((t: number) => number);
115
+ speed?: number;
116
+ once?: boolean;
117
+ axis?: 'x' | 'y';
118
+ scrollContainer?: string | Element;
119
+ native?: boolean;
120
+ onProgress?: (alpha: number) => void;
121
+ onComplete?: () => void;
122
+ }
123
+
124
+ interface ScrollCounterOptions {
125
+ from?: number;
126
+ to: number;
127
+ format?: (value: number) => string;
128
+ easing?: EasingName | ((t: number) => number);
129
+ trigger?: TriggerConfig;
130
+ once?: boolean;
131
+ decimals?: number;
132
+ onComplete?: () => void;
133
+ }
134
+
135
+ interface ScrollVideoOptions {
136
+ trigger?: TriggerConfig;
137
+ from?: number;
138
+ to?: number;
139
+ easing?: EasingName | ((t: number) => number);
140
+ once?: boolean;
141
+ axis?: 'x' | 'y';
142
+ preload?: 'auto' | 'metadata';
143
+ onReady?: () => void;
144
+ onComplete?: () => void;
145
+ onProgress?: (alpha: number) => void;
146
+ }
147
+
148
+ interface ScrollTextOptions {
149
+ split?: 'chars' | 'words' | 'lines';
150
+ stagger?: number;
151
+ easing?: EasingName | ((t: number) => number);
152
+ from?: {
153
+ opacity?: number;
154
+ y?: number;
155
+ x?: number;
156
+ rotate?: number;
157
+ scale?: number;
158
+ };
159
+ trigger?: TriggerConfig;
160
+ once?: boolean;
161
+ onComplete?: () => void;
162
+ }
163
+
111
164
  /** Composable — attach to any container ref. */
112
165
  declare function useScrollDraw(options?: ScrollDrawOptions): vue.Ref<HTMLElement | null, HTMLElement | null>;
113
166
  /** Component — wraps children in a <div> and initialises the engine. */
@@ -192,5 +245,213 @@ declare const ScrollDraw: vue.DefineComponent<vue.ExtractPropTypes<{
192
245
  once: boolean;
193
246
  debug: boolean;
194
247
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
248
+ /**
249
+ * Composable — call with a full options object and bind the returned ref to
250
+ * whichever element you want to animate.
251
+ *
252
+ * @example
253
+ * <script setup>
254
+ * import { useScrollAnimate } from 'svg-scroll-draw/vue';
255
+ * const el = useScrollAnimate({ props: { opacity: [0, 1] }, easing: 'ease-out', once: true });
256
+ * </script>
257
+ * <div :ref="el">...</div>
258
+ */
259
+ declare function useScrollAnimate(options: ScrollAnimateOptions): vue.Ref<HTMLElement | null, HTMLElement | null>;
260
+ /**
261
+ * Component — accepts a single `:options` prop and wraps children in a <div>.
262
+ *
263
+ * @example
264
+ * <ScrollAnimate :options="{ props: { opacity: [0, 1] }, easing: 'ease-out' }">
265
+ * <div>...</div>
266
+ * </ScrollAnimate>
267
+ */
268
+ declare const ScrollAnimate: vue.DefineComponent<vue.ExtractPropTypes<{
269
+ options: {
270
+ type: () => ScrollAnimateOptions;
271
+ required: true;
272
+ };
273
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
274
+ [key: string]: any;
275
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
276
+ options: {
277
+ type: () => ScrollAnimateOptions;
278
+ required: true;
279
+ };
280
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
281
+ /**
282
+ * Composable — returns a ref to bind to a span/element that will count up on scroll.
283
+ *
284
+ * @example
285
+ * <script setup>
286
+ * import { useScrollCounter } from 'svg-scroll-draw/vue';
287
+ * const el = useScrollCounter({ to: 1000, easing: 'ease-out', once: true });
288
+ * </script>
289
+ * <span :ref="el" />
290
+ */
291
+ declare function useScrollCounter(options: ScrollCounterOptions): vue.Ref<HTMLElement | null, HTMLElement | null>;
292
+ /**
293
+ * Component — renders a <span> that counts from `from` to `to` on scroll.
294
+ *
295
+ * @example
296
+ * <ScrollCounter :to="1250000" :format="n => '$' + Math.round(n).toLocaleString()" />
297
+ */
298
+ declare const ScrollCounter: vue.DefineComponent<vue.ExtractPropTypes<{
299
+ to: {
300
+ type: NumberConstructor;
301
+ required: true;
302
+ };
303
+ from: {
304
+ type: NumberConstructor;
305
+ };
306
+ format: {
307
+ type: () => ScrollCounterOptions["format"];
308
+ };
309
+ easing: {
310
+ type: (StringConstructor | FunctionConstructor)[];
311
+ };
312
+ trigger: {
313
+ type: ObjectConstructor;
314
+ };
315
+ once: {
316
+ type: BooleanConstructor;
317
+ };
318
+ decimals: {
319
+ type: NumberConstructor;
320
+ };
321
+ onComplete: {
322
+ type: FunctionConstructor;
323
+ };
324
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
325
+ [key: string]: any;
326
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
327
+ to: {
328
+ type: NumberConstructor;
329
+ required: true;
330
+ };
331
+ from: {
332
+ type: NumberConstructor;
333
+ };
334
+ format: {
335
+ type: () => ScrollCounterOptions["format"];
336
+ };
337
+ easing: {
338
+ type: (StringConstructor | FunctionConstructor)[];
339
+ };
340
+ trigger: {
341
+ type: ObjectConstructor;
342
+ };
343
+ once: {
344
+ type: BooleanConstructor;
345
+ };
346
+ decimals: {
347
+ type: NumberConstructor;
348
+ };
349
+ onComplete: {
350
+ type: FunctionConstructor;
351
+ };
352
+ }>> & Readonly<{}>, {
353
+ once: boolean;
354
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
355
+ /**
356
+ * Composable — returns a ref to bind to a <video> element.
357
+ *
358
+ * @example
359
+ * <script setup>
360
+ * import { useScrollVideo } from 'svg-scroll-draw/vue';
361
+ * const vid = useScrollVideo({ trigger: { start: 'top top', end: 'bottom top' } });
362
+ * </script>
363
+ * <video :ref="vid" src="..." muted playsinline preload="auto" />
364
+ */
365
+ declare function useScrollVideo(options?: ScrollVideoOptions): vue.Ref<HTMLVideoElement | null, HTMLVideoElement | null>;
366
+ /**
367
+ * Component — renders a <video> scrubbed by scroll position.
368
+ *
369
+ * @example
370
+ * <ScrollVideo src="/hero.mp4" :options="{ trigger: { start: 'top top', end: 'bottom top' } }" />
371
+ */
372
+ declare const ScrollVideo: vue.DefineComponent<vue.ExtractPropTypes<{
373
+ src: {
374
+ type: StringConstructor;
375
+ required: true;
376
+ };
377
+ options: {
378
+ type: () => ScrollVideoOptions;
379
+ };
380
+ muted: {
381
+ type: BooleanConstructor;
382
+ default: boolean;
383
+ };
384
+ playsInline: {
385
+ type: BooleanConstructor;
386
+ default: boolean;
387
+ };
388
+ class: {
389
+ type: StringConstructor;
390
+ };
391
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
392
+ [key: string]: any;
393
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
394
+ src: {
395
+ type: StringConstructor;
396
+ required: true;
397
+ };
398
+ options: {
399
+ type: () => ScrollVideoOptions;
400
+ };
401
+ muted: {
402
+ type: BooleanConstructor;
403
+ default: boolean;
404
+ };
405
+ playsInline: {
406
+ type: BooleanConstructor;
407
+ default: boolean;
408
+ };
409
+ class: {
410
+ type: StringConstructor;
411
+ };
412
+ }>> & Readonly<{}>, {
413
+ muted: boolean;
414
+ playsInline: boolean;
415
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
416
+ /**
417
+ * Composable — returns a ref to bind to any text element; splits and animates on scroll.
418
+ *
419
+ * @example
420
+ * <script setup>
421
+ * import { useScrollText } from 'svg-scroll-draw/vue';
422
+ * const el = useScrollText({ split: 'words', stagger: 0.05, once: true });
423
+ * </script>
424
+ * <h2 :ref="el">Animate on scroll.</h2>
425
+ */
426
+ declare function useScrollText(options?: ScrollTextOptions): vue.Ref<HTMLElement | null, HTMLElement | null>;
427
+ /**
428
+ * Component — wraps text content in a <p> (or any tag) and animates it on scroll.
429
+ *
430
+ * @example
431
+ * <ScrollText :options="{ split: 'words', stagger: 0.05 }" tag="h2">
432
+ * Animate on scroll.
433
+ * </ScrollText>
434
+ */
435
+ declare const ScrollText: vue.DefineComponent<vue.ExtractPropTypes<{
436
+ options: {
437
+ type: () => ScrollTextOptions;
438
+ };
439
+ tag: {
440
+ type: StringConstructor;
441
+ default: string;
442
+ };
443
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
444
+ [key: string]: any;
445
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
446
+ options: {
447
+ type: () => ScrollTextOptions;
448
+ };
449
+ tag: {
450
+ type: StringConstructor;
451
+ default: string;
452
+ };
453
+ }>> & Readonly<{}>, {
454
+ tag: string;
455
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
195
456
 
196
- export { ScrollDraw, type ScrollDrawOptions, useScrollDraw };
457
+ export { ScrollAnimate, type ScrollAnimateOptions, ScrollCounter, type ScrollCounterOptions, ScrollDraw, type ScrollDrawOptions, ScrollText, type ScrollTextOptions, ScrollVideo, type ScrollVideoOptions, useScrollAnimate, useScrollCounter, useScrollDraw, useScrollText, useScrollVideo };
@@ -108,6 +108,59 @@ interface ScrollDrawOptions {
108
108
  native?: boolean;
109
109
  }
110
110
 
111
+ interface ScrollAnimateOptions {
112
+ props: Record<string, string | number | [string | number, string | number]>;
113
+ trigger?: TriggerConfig;
114
+ easing?: EasingName | ((t: number) => number);
115
+ speed?: number;
116
+ once?: boolean;
117
+ axis?: 'x' | 'y';
118
+ scrollContainer?: string | Element;
119
+ native?: boolean;
120
+ onProgress?: (alpha: number) => void;
121
+ onComplete?: () => void;
122
+ }
123
+
124
+ interface ScrollCounterOptions {
125
+ from?: number;
126
+ to: number;
127
+ format?: (value: number) => string;
128
+ easing?: EasingName | ((t: number) => number);
129
+ trigger?: TriggerConfig;
130
+ once?: boolean;
131
+ decimals?: number;
132
+ onComplete?: () => void;
133
+ }
134
+
135
+ interface ScrollVideoOptions {
136
+ trigger?: TriggerConfig;
137
+ from?: number;
138
+ to?: number;
139
+ easing?: EasingName | ((t: number) => number);
140
+ once?: boolean;
141
+ axis?: 'x' | 'y';
142
+ preload?: 'auto' | 'metadata';
143
+ onReady?: () => void;
144
+ onComplete?: () => void;
145
+ onProgress?: (alpha: number) => void;
146
+ }
147
+
148
+ interface ScrollTextOptions {
149
+ split?: 'chars' | 'words' | 'lines';
150
+ stagger?: number;
151
+ easing?: EasingName | ((t: number) => number);
152
+ from?: {
153
+ opacity?: number;
154
+ y?: number;
155
+ x?: number;
156
+ rotate?: number;
157
+ scale?: number;
158
+ };
159
+ trigger?: TriggerConfig;
160
+ once?: boolean;
161
+ onComplete?: () => void;
162
+ }
163
+
111
164
  /** Composable — attach to any container ref. */
112
165
  declare function useScrollDraw(options?: ScrollDrawOptions): vue.Ref<HTMLElement | null, HTMLElement | null>;
113
166
  /** Component — wraps children in a <div> and initialises the engine. */
@@ -192,5 +245,213 @@ declare const ScrollDraw: vue.DefineComponent<vue.ExtractPropTypes<{
192
245
  once: boolean;
193
246
  debug: boolean;
194
247
  }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
248
+ /**
249
+ * Composable — call with a full options object and bind the returned ref to
250
+ * whichever element you want to animate.
251
+ *
252
+ * @example
253
+ * <script setup>
254
+ * import { useScrollAnimate } from 'svg-scroll-draw/vue';
255
+ * const el = useScrollAnimate({ props: { opacity: [0, 1] }, easing: 'ease-out', once: true });
256
+ * </script>
257
+ * <div :ref="el">...</div>
258
+ */
259
+ declare function useScrollAnimate(options: ScrollAnimateOptions): vue.Ref<HTMLElement | null, HTMLElement | null>;
260
+ /**
261
+ * Component — accepts a single `:options` prop and wraps children in a <div>.
262
+ *
263
+ * @example
264
+ * <ScrollAnimate :options="{ props: { opacity: [0, 1] }, easing: 'ease-out' }">
265
+ * <div>...</div>
266
+ * </ScrollAnimate>
267
+ */
268
+ declare const ScrollAnimate: vue.DefineComponent<vue.ExtractPropTypes<{
269
+ options: {
270
+ type: () => ScrollAnimateOptions;
271
+ required: true;
272
+ };
273
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
274
+ [key: string]: any;
275
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
276
+ options: {
277
+ type: () => ScrollAnimateOptions;
278
+ required: true;
279
+ };
280
+ }>> & Readonly<{}>, {}, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
281
+ /**
282
+ * Composable — returns a ref to bind to a span/element that will count up on scroll.
283
+ *
284
+ * @example
285
+ * <script setup>
286
+ * import { useScrollCounter } from 'svg-scroll-draw/vue';
287
+ * const el = useScrollCounter({ to: 1000, easing: 'ease-out', once: true });
288
+ * </script>
289
+ * <span :ref="el" />
290
+ */
291
+ declare function useScrollCounter(options: ScrollCounterOptions): vue.Ref<HTMLElement | null, HTMLElement | null>;
292
+ /**
293
+ * Component — renders a <span> that counts from `from` to `to` on scroll.
294
+ *
295
+ * @example
296
+ * <ScrollCounter :to="1250000" :format="n => '$' + Math.round(n).toLocaleString()" />
297
+ */
298
+ declare const ScrollCounter: vue.DefineComponent<vue.ExtractPropTypes<{
299
+ to: {
300
+ type: NumberConstructor;
301
+ required: true;
302
+ };
303
+ from: {
304
+ type: NumberConstructor;
305
+ };
306
+ format: {
307
+ type: () => ScrollCounterOptions["format"];
308
+ };
309
+ easing: {
310
+ type: (StringConstructor | FunctionConstructor)[];
311
+ };
312
+ trigger: {
313
+ type: ObjectConstructor;
314
+ };
315
+ once: {
316
+ type: BooleanConstructor;
317
+ };
318
+ decimals: {
319
+ type: NumberConstructor;
320
+ };
321
+ onComplete: {
322
+ type: FunctionConstructor;
323
+ };
324
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
325
+ [key: string]: any;
326
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
327
+ to: {
328
+ type: NumberConstructor;
329
+ required: true;
330
+ };
331
+ from: {
332
+ type: NumberConstructor;
333
+ };
334
+ format: {
335
+ type: () => ScrollCounterOptions["format"];
336
+ };
337
+ easing: {
338
+ type: (StringConstructor | FunctionConstructor)[];
339
+ };
340
+ trigger: {
341
+ type: ObjectConstructor;
342
+ };
343
+ once: {
344
+ type: BooleanConstructor;
345
+ };
346
+ decimals: {
347
+ type: NumberConstructor;
348
+ };
349
+ onComplete: {
350
+ type: FunctionConstructor;
351
+ };
352
+ }>> & Readonly<{}>, {
353
+ once: boolean;
354
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
355
+ /**
356
+ * Composable — returns a ref to bind to a <video> element.
357
+ *
358
+ * @example
359
+ * <script setup>
360
+ * import { useScrollVideo } from 'svg-scroll-draw/vue';
361
+ * const vid = useScrollVideo({ trigger: { start: 'top top', end: 'bottom top' } });
362
+ * </script>
363
+ * <video :ref="vid" src="..." muted playsinline preload="auto" />
364
+ */
365
+ declare function useScrollVideo(options?: ScrollVideoOptions): vue.Ref<HTMLVideoElement | null, HTMLVideoElement | null>;
366
+ /**
367
+ * Component — renders a <video> scrubbed by scroll position.
368
+ *
369
+ * @example
370
+ * <ScrollVideo src="/hero.mp4" :options="{ trigger: { start: 'top top', end: 'bottom top' } }" />
371
+ */
372
+ declare const ScrollVideo: vue.DefineComponent<vue.ExtractPropTypes<{
373
+ src: {
374
+ type: StringConstructor;
375
+ required: true;
376
+ };
377
+ options: {
378
+ type: () => ScrollVideoOptions;
379
+ };
380
+ muted: {
381
+ type: BooleanConstructor;
382
+ default: boolean;
383
+ };
384
+ playsInline: {
385
+ type: BooleanConstructor;
386
+ default: boolean;
387
+ };
388
+ class: {
389
+ type: StringConstructor;
390
+ };
391
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
392
+ [key: string]: any;
393
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
394
+ src: {
395
+ type: StringConstructor;
396
+ required: true;
397
+ };
398
+ options: {
399
+ type: () => ScrollVideoOptions;
400
+ };
401
+ muted: {
402
+ type: BooleanConstructor;
403
+ default: boolean;
404
+ };
405
+ playsInline: {
406
+ type: BooleanConstructor;
407
+ default: boolean;
408
+ };
409
+ class: {
410
+ type: StringConstructor;
411
+ };
412
+ }>> & Readonly<{}>, {
413
+ muted: boolean;
414
+ playsInline: boolean;
415
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
416
+ /**
417
+ * Composable — returns a ref to bind to any text element; splits and animates on scroll.
418
+ *
419
+ * @example
420
+ * <script setup>
421
+ * import { useScrollText } from 'svg-scroll-draw/vue';
422
+ * const el = useScrollText({ split: 'words', stagger: 0.05, once: true });
423
+ * </script>
424
+ * <h2 :ref="el">Animate on scroll.</h2>
425
+ */
426
+ declare function useScrollText(options?: ScrollTextOptions): vue.Ref<HTMLElement | null, HTMLElement | null>;
427
+ /**
428
+ * Component — wraps text content in a <p> (or any tag) and animates it on scroll.
429
+ *
430
+ * @example
431
+ * <ScrollText :options="{ split: 'words', stagger: 0.05 }" tag="h2">
432
+ * Animate on scroll.
433
+ * </ScrollText>
434
+ */
435
+ declare const ScrollText: vue.DefineComponent<vue.ExtractPropTypes<{
436
+ options: {
437
+ type: () => ScrollTextOptions;
438
+ };
439
+ tag: {
440
+ type: StringConstructor;
441
+ default: string;
442
+ };
443
+ }>, () => vue.VNode<vue.RendererNode, vue.RendererElement, {
444
+ [key: string]: any;
445
+ }>, {}, {}, {}, vue.ComponentOptionsMixin, vue.ComponentOptionsMixin, {}, string, vue.PublicProps, Readonly<vue.ExtractPropTypes<{
446
+ options: {
447
+ type: () => ScrollTextOptions;
448
+ };
449
+ tag: {
450
+ type: StringConstructor;
451
+ default: string;
452
+ };
453
+ }>> & Readonly<{}>, {
454
+ tag: string;
455
+ }, {}, {}, {}, string, vue.ComponentProvideOptions, true, {}, any>;
195
456
 
196
- export { ScrollDraw, type ScrollDrawOptions, useScrollDraw };
457
+ export { ScrollAnimate, type ScrollAnimateOptions, ScrollCounter, type ScrollCounterOptions, ScrollDraw, type ScrollDrawOptions, ScrollText, type ScrollTextOptions, ScrollVideo, type ScrollVideoOptions, useScrollAnimate, useScrollCounter, useScrollDraw, useScrollText, useScrollVideo };