svg-scroll-draw 2.14.0 → 2.15.1
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 +58 -0
- package/dist/angular/index.cjs +2 -2
- package/dist/angular/index.mjs +2 -2
- package/dist/aos/react/index.cjs +3 -0
- package/dist/aos/react/index.mjs +3 -0
- package/dist/astro/index.cjs +2 -2
- package/dist/astro/index.mjs +2 -2
- package/dist/cdn/svg-scroll-draw.dev.global.js +18 -4
- package/dist/cdn/svg-scroll-draw.global.js +2 -2
- package/dist/group/index.cjs +2 -2
- package/dist/group/index.mjs +2 -2
- package/dist/index.cjs +3 -3
- package/dist/index.mjs +3 -3
- package/dist/nuxt/index.cjs +2 -2
- package/dist/nuxt/index.mjs +2 -2
- package/dist/react/index.cjs +2 -2
- package/dist/react/index.mjs +2 -2
- package/dist/scrollreveal/react/index.cjs +3 -0
- package/dist/scrollreveal/react/index.d.mts +58 -0
- package/dist/scrollreveal/react/index.d.ts +58 -0
- package/dist/scrollreveal/react/index.mjs +3 -0
- package/dist/solid/index.cjs +2 -2
- package/dist/solid/index.mjs +2 -2
- package/dist/svelte/index.cjs +2 -2
- package/dist/svelte/index.mjs +2 -2
- package/dist/vivus/react/index.cjs +2 -0
- package/dist/vivus/react/index.mjs +2 -0
- package/dist/vue/index.cjs +2 -2
- package/dist/vue/index.mjs +2 -2
- package/dist/web-component/index.cjs +2 -2
- package/dist/web-component/index.mjs +2 -2
- package/package.json +47 -2
- package/dist/horizontal/index.d.mts +0 -108
- package/dist/horizontal/index.d.ts +0 -108
- package/dist/lenis/index.d.mts +0 -51
- package/dist/lenis/index.d.ts +0 -51
|
@@ -1,108 +0,0 @@
|
|
|
1
|
-
type EasingName = 'linear' | 'ease-in' | 'ease-out' | 'ease-in-out' | 'spring' | 'bounce' | 'elastic';
|
|
2
|
-
interface TriggerConfig {
|
|
3
|
-
start?: string;
|
|
4
|
-
end?: string;
|
|
5
|
-
}
|
|
6
|
-
interface ScrollDrawInstance {
|
|
7
|
-
destroy: () => void;
|
|
8
|
-
/** Reset and replay the animation from the beginning. */
|
|
9
|
-
replay: () => void;
|
|
10
|
-
/** Pause the animation at the current progress. */
|
|
11
|
-
pause: () => void;
|
|
12
|
-
/** Resume a paused animation. */
|
|
13
|
-
resume: () => void;
|
|
14
|
-
/** Jump to a specific progress value (0–1) and pause. */
|
|
15
|
-
seek: (progress: number) => void;
|
|
16
|
-
/** Returns current draw progress (0–1). */
|
|
17
|
-
getProgress: () => number;
|
|
18
|
-
/**
|
|
19
|
-
* Re-measure after a layout change: path lengths, and the scroll trigger window.
|
|
20
|
-
*
|
|
21
|
-
* The engine already re-measures on `resize`, on `orientationchange`, and via a
|
|
22
|
-
* `ResizeObserver` on the document element — but none of those fire for a layout
|
|
23
|
-
* change that leaves the document height alone, such as a tab switching, a
|
|
24
|
-
* sibling collapsing, or a font swapping inside a fixed-height box. Call this
|
|
25
|
-
* after one of those.
|
|
26
|
-
*
|
|
27
|
-
* Optional on this shared type because several instances here are fan-outs over
|
|
28
|
-
* other instances or SSR no-op stubs. `scrollDraw`, `scrollPin`,
|
|
29
|
-
* `scrollHorizontal`, `scrollDrawTimeline` and the group APIs all provide it;
|
|
30
|
-
* use `instance.refresh?.()` if you hold an instance of unknown origin.
|
|
31
|
-
*/
|
|
32
|
-
refresh?: () => void;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
interface ScrollHorizontalOptions {
|
|
36
|
-
/**
|
|
37
|
-
* Total horizontal travel distance in pixels.
|
|
38
|
-
*
|
|
39
|
-
* Default: `track.scrollWidth` minus the width it is seen through — the
|
|
40
|
-
* viewport, or the `scrollContainer`'s client width when one is given.
|
|
41
|
-
*/
|
|
42
|
-
distance?: number;
|
|
43
|
-
/**
|
|
44
|
-
* Trigger window for the scroll → horizontal mapping.
|
|
45
|
-
* Default: `{ start: 'top top', end: 'bottom bottom' }` — full container height.
|
|
46
|
-
*/
|
|
47
|
-
trigger?: TriggerConfig;
|
|
48
|
-
/** Easing for the horizontal movement. Default: `'linear'` (scrub feel). */
|
|
49
|
-
easing?: EasingName | ((t: number) => number);
|
|
50
|
-
/** Custom scroll container. Default: window. */
|
|
51
|
-
scrollContainer?: string | Element;
|
|
52
|
-
/**
|
|
53
|
-
* Element whose height defines the scroll window for the scrub.
|
|
54
|
-
*
|
|
55
|
-
* Default: the container of the track's nearest `position: sticky` ancestor —
|
|
56
|
-
* the `.outer` element in the CSS setup below, which is where the scroll room
|
|
57
|
-
* actually lives. Falls back to the track itself when there is no sticky
|
|
58
|
-
* ancestor.
|
|
59
|
-
*
|
|
60
|
-
* Why this is not the track: a sticky stage pins the track at exactly one
|
|
61
|
-
* viewport tall, so measuring `top top` → `bottom bottom` against it gives
|
|
62
|
-
* tStart === tEnd — a zero-length window, and a track that never moves.
|
|
63
|
-
*/
|
|
64
|
-
triggerElement?: string | Element;
|
|
65
|
-
/**
|
|
66
|
-
* Honour `prefers-reduced-motion: reduce` by holding the track at its final
|
|
67
|
-
* position instead of scrubbing. Default: **`false`** — unlike every other
|
|
68
|
-
* API here, which defaults to `true`.
|
|
69
|
-
*
|
|
70
|
-
* The reasoning: this transform is scroll-linked scrubbing, not autonomous
|
|
71
|
-
* motion. It advances only as the user scrolls, 1:1 with their input, so it is
|
|
72
|
-
* direct manipulation rather than something that plays at them. And the
|
|
73
|
-
* alternative is worse than the motion — the panels are only reachable *via*
|
|
74
|
-
* the transform, inside a sticky `overflow: hidden` container, so applying a
|
|
75
|
-
* final state (or none at all) silently hides all of the content except one
|
|
76
|
-
* panel from exactly the users who asked for less motion.
|
|
77
|
-
*
|
|
78
|
-
* Set to `true` if your layout has an accessible non-transform fallback and you
|
|
79
|
-
* would rather drop the movement.
|
|
80
|
-
*/
|
|
81
|
-
respectReducedMotion?: boolean;
|
|
82
|
-
onProgress?: (progress: number) => void;
|
|
83
|
-
}
|
|
84
|
-
interface ScrollHorizontalInstance extends ScrollDrawInstance {
|
|
85
|
-
/** Recalculate travel distance after layout change. */
|
|
86
|
-
refresh: () => void;
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Drive horizontal movement (translateX) from vertical scroll.
|
|
90
|
-
*
|
|
91
|
-
* The Apple / Stripe "scroll to reveal horizontal sections" pattern.
|
|
92
|
-
* You handle the sticky + overflow CSS; `scrollHorizontal` drives the translateX.
|
|
93
|
-
*
|
|
94
|
-
* Minimal CSS setup:
|
|
95
|
-
* .outer { height: 400vh; }
|
|
96
|
-
* .sticky { position: sticky; top: 0; height: 100vh; overflow: hidden; }
|
|
97
|
-
* .track { display: flex; width: max-content; }
|
|
98
|
-
*
|
|
99
|
-
* @example
|
|
100
|
-
* scrollHorizontal('.track', {
|
|
101
|
-
* distance: 3 * window.innerWidth,
|
|
102
|
-
* trigger: { start: 'top top', end: 'bottom bottom' },
|
|
103
|
-
* easing: 'linear',
|
|
104
|
-
* });
|
|
105
|
-
*/
|
|
106
|
-
declare function scrollHorizontal(track: string | Element, options?: ScrollHorizontalOptions): ScrollHorizontalInstance;
|
|
107
|
-
|
|
108
|
-
export { type ScrollHorizontalInstance, type ScrollHorizontalOptions, scrollHorizontal };
|
package/dist/lenis/index.d.mts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lenis smooth-scroll adapter for svg-scroll-draw.
|
|
3
|
-
*
|
|
4
|
-
* Lenis v2+ patches `window.scrollY` natively — no adapter needed.
|
|
5
|
-
* This adapter targets Lenis v1, which uses a virtual scroll value
|
|
6
|
-
* and does NOT update `window.scrollY`. It patches `window.scrollY` /
|
|
7
|
-
* `window.pageYOffset` so all svg-scroll-draw engines read the correct value.
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* import Lenis from '@studio-freight/lenis'
|
|
11
|
-
* import { createLenisAdapter } from 'svg-scroll-draw/lenis'
|
|
12
|
-
*
|
|
13
|
-
* const lenis = new Lenis()
|
|
14
|
-
* const adapter = createLenisAdapter(lenis)
|
|
15
|
-
*
|
|
16
|
-
* // RAF loop — let Lenis drive the tick
|
|
17
|
-
* function raf(time: number) {
|
|
18
|
-
* lenis.raf(time)
|
|
19
|
-
* requestAnimationFrame(raf)
|
|
20
|
-
* }
|
|
21
|
-
* requestAnimationFrame(raf)
|
|
22
|
-
*
|
|
23
|
-
* // On cleanup:
|
|
24
|
-
* adapter.destroy()
|
|
25
|
-
*/
|
|
26
|
-
interface LenisScrollEvent {
|
|
27
|
-
scroll: number;
|
|
28
|
-
velocity: number;
|
|
29
|
-
direction: number;
|
|
30
|
-
progress: number;
|
|
31
|
-
}
|
|
32
|
-
interface LenisLike {
|
|
33
|
-
on(event: 'scroll', callback: (e: LenisScrollEvent) => void): void;
|
|
34
|
-
off(event: 'scroll', callback: (e: LenisScrollEvent) => void): void;
|
|
35
|
-
}
|
|
36
|
-
interface LenisAdapterInstance {
|
|
37
|
-
/** Restore native `window.scrollY` and remove the Lenis listener. */
|
|
38
|
-
destroy: () => void;
|
|
39
|
-
/** Returns the current virtual scroll Y value Lenis last reported. */
|
|
40
|
-
getScrollY: () => number;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Patches `window.scrollY` and `window.pageYOffset` to return Lenis's
|
|
44
|
-
* virtual scroll position so all svg-scroll-draw engines stay in sync
|
|
45
|
-
* with smooth scroll.
|
|
46
|
-
*
|
|
47
|
-
* Only needed for Lenis v1. Lenis v2+ patches scrollY itself.
|
|
48
|
-
*/
|
|
49
|
-
declare function createLenisAdapter(lenis: LenisLike): LenisAdapterInstance;
|
|
50
|
-
|
|
51
|
-
export { type LenisAdapterInstance, type LenisLike, type LenisScrollEvent, createLenisAdapter };
|
package/dist/lenis/index.d.ts
DELETED
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Lenis smooth-scroll adapter for svg-scroll-draw.
|
|
3
|
-
*
|
|
4
|
-
* Lenis v2+ patches `window.scrollY` natively — no adapter needed.
|
|
5
|
-
* This adapter targets Lenis v1, which uses a virtual scroll value
|
|
6
|
-
* and does NOT update `window.scrollY`. It patches `window.scrollY` /
|
|
7
|
-
* `window.pageYOffset` so all svg-scroll-draw engines read the correct value.
|
|
8
|
-
*
|
|
9
|
-
* Usage:
|
|
10
|
-
* import Lenis from '@studio-freight/lenis'
|
|
11
|
-
* import { createLenisAdapter } from 'svg-scroll-draw/lenis'
|
|
12
|
-
*
|
|
13
|
-
* const lenis = new Lenis()
|
|
14
|
-
* const adapter = createLenisAdapter(lenis)
|
|
15
|
-
*
|
|
16
|
-
* // RAF loop — let Lenis drive the tick
|
|
17
|
-
* function raf(time: number) {
|
|
18
|
-
* lenis.raf(time)
|
|
19
|
-
* requestAnimationFrame(raf)
|
|
20
|
-
* }
|
|
21
|
-
* requestAnimationFrame(raf)
|
|
22
|
-
*
|
|
23
|
-
* // On cleanup:
|
|
24
|
-
* adapter.destroy()
|
|
25
|
-
*/
|
|
26
|
-
interface LenisScrollEvent {
|
|
27
|
-
scroll: number;
|
|
28
|
-
velocity: number;
|
|
29
|
-
direction: number;
|
|
30
|
-
progress: number;
|
|
31
|
-
}
|
|
32
|
-
interface LenisLike {
|
|
33
|
-
on(event: 'scroll', callback: (e: LenisScrollEvent) => void): void;
|
|
34
|
-
off(event: 'scroll', callback: (e: LenisScrollEvent) => void): void;
|
|
35
|
-
}
|
|
36
|
-
interface LenisAdapterInstance {
|
|
37
|
-
/** Restore native `window.scrollY` and remove the Lenis listener. */
|
|
38
|
-
destroy: () => void;
|
|
39
|
-
/** Returns the current virtual scroll Y value Lenis last reported. */
|
|
40
|
-
getScrollY: () => number;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Patches `window.scrollY` and `window.pageYOffset` to return Lenis's
|
|
44
|
-
* virtual scroll position so all svg-scroll-draw engines stay in sync
|
|
45
|
-
* with smooth scroll.
|
|
46
|
-
*
|
|
47
|
-
* Only needed for Lenis v1. Lenis v2+ patches scrollY itself.
|
|
48
|
-
*/
|
|
49
|
-
declare function createLenisAdapter(lenis: LenisLike): LenisAdapterInstance;
|
|
50
|
-
|
|
51
|
-
export { type LenisAdapterInstance, type LenisLike, type LenisScrollEvent, createLenisAdapter };
|