lenis 1.3.19 → 1.3.20-dev.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.
@@ -1,86 +1,99 @@
1
- import Lenis, { EasingFunction, VirtualScrollData } from 'lenis';
1
+ import Lenis, { EasingFunction, VirtualScrollData } from "lenis";
2
2
 
3
+ //#region packages/snap/src/element.d.ts
3
4
  type SnapElementOptions = {
4
- align?: string | string[];
5
- ignoreSticky?: boolean;
6
- ignoreTransform?: boolean;
5
+ align?: string | string[];
6
+ ignoreSticky?: boolean;
7
+ ignoreTransform?: boolean;
7
8
  };
8
9
  type Rect = {
9
- top: number;
10
- left: number;
11
- width: number;
12
- height: number;
13
- x: number;
14
- y: number;
15
- bottom: number;
16
- right: number;
17
- element: HTMLElement;
10
+ top: number;
11
+ left: number;
12
+ width: number;
13
+ height: number;
14
+ x: number;
15
+ y: number;
16
+ bottom: number;
17
+ right: number;
18
+ element: HTMLElement;
18
19
  };
19
20
  declare class SnapElement {
20
- element: HTMLElement;
21
- options: SnapElementOptions;
22
- align: string[];
23
- rect: Rect;
24
- wrapperResizeObserver: ResizeObserver;
25
- resizeObserver: ResizeObserver;
26
- debouncedWrapperResize: () => void;
27
- constructor(element: HTMLElement, { align, ignoreSticky, ignoreTransform, }?: SnapElementOptions);
28
- destroy(): void;
29
- setRect({ top, left, width, height, element, }?: {
30
- top?: number;
31
- left?: number;
32
- width?: number;
33
- height?: number;
34
- element?: HTMLElement;
35
- }): void;
36
- onWrapperResize: () => void;
37
- onResize: ([entry]: ResizeObserverEntry[]) => void;
21
+ element: HTMLElement;
22
+ options: SnapElementOptions;
23
+ align: string[];
24
+ rect: Rect;
25
+ wrapperResizeObserver: ResizeObserver;
26
+ resizeObserver: ResizeObserver;
27
+ debouncedWrapperResize: () => void;
28
+ constructor(element: HTMLElement, {
29
+ align,
30
+ ignoreSticky,
31
+ ignoreTransform
32
+ }?: SnapElementOptions);
33
+ destroy(): void;
34
+ setRect({
35
+ top,
36
+ left,
37
+ width,
38
+ height,
39
+ element
40
+ }?: {
41
+ top?: number;
42
+ left?: number;
43
+ width?: number;
44
+ height?: number;
45
+ element?: HTMLElement;
46
+ }): void;
47
+ onWrapperResize: () => void;
48
+ onResize: ([entry]: ResizeObserverEntry[]) => void;
38
49
  }
39
-
50
+ //#endregion
51
+ //#region packages/snap/src/types.d.ts
40
52
  type SnapItem = {
41
- value: number;
53
+ value: number;
42
54
  };
43
55
  type OnSnapCallback = (item: SnapItem & {
44
- index?: number;
56
+ index?: number;
45
57
  }) => void;
46
58
  type SnapOptions = {
47
- /**
48
- * Snap type
49
- * @default 'proximity'
50
- */
51
- type?: 'mandatory' | 'proximity' | 'lock';
52
- /**
53
- * @description Linear interpolation (lerp) intensity (between 0 and 1)
54
- */
55
- lerp?: number;
56
- /**
57
- * @description The easing function to use for the snap animation
58
- */
59
- easing?: EasingFunction;
60
- /**
61
- * @description The duration of the snap animation (in s)
62
- */
63
- duration?: number;
64
- /**
65
- * @default '50%'
66
- * @description The distance threshold from the snap point to the scroll position. Ignored when `type` is `mandatory`. If a percentage, it is relative to the viewport size. If a number, it is absolute.
67
- */
68
- distanceThreshold?: number | `${number}%`;
69
- /**
70
- * @default 500
71
- * @description The debounce delay (in ms) to prevent snapping too often.
72
- */
73
- debounce?: number;
74
- /**
75
- * @description Called when the snap starts
76
- */
77
- onSnapStart?: OnSnapCallback;
78
- /**
79
- * @description Called when the snap completes
80
- */
81
- onSnapComplete?: OnSnapCallback;
59
+ /**
60
+ * Snap type
61
+ * @default 'proximity'
62
+ */
63
+ type?: 'mandatory' | 'proximity' | 'lock';
64
+ /**
65
+ * @description Linear interpolation (lerp) intensity (between 0 and 1)
66
+ */
67
+ lerp?: number;
68
+ /**
69
+ * @description The easing function to use for the snap animation
70
+ */
71
+ easing?: EasingFunction;
72
+ /**
73
+ * @description The duration of the snap animation (in s)
74
+ */
75
+ duration?: number;
76
+ /**
77
+ * @default '50%'
78
+ * @description The distance threshold from the snap point to the scroll position. Ignored when `type` is `mandatory`. If a percentage, it is relative to the viewport size. If a number, it is absolute.
79
+ */
80
+ distanceThreshold?: number | `${number}%`;
81
+ /**
82
+ * @default 500
83
+ * @description The debounce delay (in ms) to prevent snapping too often.
84
+ */
85
+ debounce?: number;
86
+ /**
87
+ * @description Called when the snap starts
88
+ */
89
+ onSnapStart?: OnSnapCallback;
90
+ /**
91
+ * @description Called when the snap completes
92
+ */
93
+ onSnapComplete?: OnSnapCallback;
82
94
  };
83
-
95
+ //#endregion
96
+ //#region packages/snap/src/snap.d.ts
84
97
  type RequiredPick<T, F extends keyof T> = Omit<T, F> & Required<Pick<T, F>>;
85
98
  /**
86
99
  * Snap class to handle the snap functionality
@@ -105,56 +118,66 @@ type RequiredPick<T, F extends keyof T> = Omit<T, F> & Required<Pick<T, F>>;
105
118
  * }
106
119
  */
107
120
  declare class Snap {
108
- private lenis;
109
- options: RequiredPick<SnapOptions, 'type' | 'debounce'>;
110
- elements: Map<number, SnapElement>;
111
- snaps: Map<number, SnapItem>;
112
- viewport: {
113
- width: number;
114
- height: number;
115
- };
116
- isStopped: boolean;
117
- onSnapDebounced: (e: VirtualScrollData) => void;
118
- currentSnapIndex?: number;
119
- constructor(lenis: Lenis, { type, lerp, easing, duration, distanceThreshold, // useless when type is "mandatory"
120
- debounce: debounceDelay, onSnapStart, onSnapComplete, }?: SnapOptions);
121
- /**
122
- * Destroy the snap instance
123
- */
124
- destroy(): void;
125
- /**
126
- * Start the snap after it has been stopped
127
- */
128
- start(): void;
129
- /**
130
- * Stop the snap
131
- */
132
- stop(): void;
133
- /**
134
- * Add a snap to the snap instance
135
- *
136
- * @param value The value to snap to
137
- * @param userData User data that will be forwarded through the snap event
138
- * @returns Unsubscribe function
139
- */
140
- add(value: number): () => void;
141
- /**
142
- * Add an element to the snap instance
143
- *
144
- * @param element The element to add
145
- * @param options The options for the element
146
- * @returns Unsubscribe function
147
- */
148
- addElement(element: HTMLElement, options?: SnapElementOptions): () => void;
149
- addElements(elements: HTMLElement[], options?: SnapElementOptions): () => void;
150
- private onWindowResize;
151
- private computeSnaps;
152
- previous(): void;
153
- next(): void;
154
- goTo(index: number): void;
155
- get distanceThreshold(): number;
156
- private onSnap;
157
- resize(): void;
121
+ private lenis;
122
+ options: RequiredPick<SnapOptions, 'type' | 'debounce'>;
123
+ elements: Map<number, SnapElement>;
124
+ snaps: Map<number, SnapItem>;
125
+ viewport: {
126
+ width: number;
127
+ height: number;
128
+ };
129
+ isStopped: boolean;
130
+ onSnapDebounced: (e: VirtualScrollData) => void;
131
+ currentSnapIndex?: number;
132
+ constructor(lenis: Lenis, {
133
+ type,
134
+ lerp,
135
+ easing,
136
+ duration,
137
+ distanceThreshold,
138
+ // useless when type is "mandatory"
139
+ debounce: debounceDelay,
140
+ onSnapStart,
141
+ onSnapComplete
142
+ }?: SnapOptions);
143
+ /**
144
+ * Destroy the snap instance
145
+ */
146
+ destroy(): void;
147
+ /**
148
+ * Start the snap after it has been stopped
149
+ */
150
+ start(): void;
151
+ /**
152
+ * Stop the snap
153
+ */
154
+ stop(): void;
155
+ /**
156
+ * Add a snap to the snap instance
157
+ *
158
+ * @param value The value to snap to
159
+ * @param userData User data that will be forwarded through the snap event
160
+ * @returns Unsubscribe function
161
+ */
162
+ add(value: number): () => void;
163
+ /**
164
+ * Add an element to the snap instance
165
+ *
166
+ * @param element The element to add
167
+ * @param options The options for the element
168
+ * @returns Unsubscribe function
169
+ */
170
+ addElement(element: HTMLElement, options?: SnapElementOptions): () => void;
171
+ addElements(elements: HTMLElement[], options?: SnapElementOptions): () => void;
172
+ private onWindowResize;
173
+ private computeSnaps;
174
+ previous(): void;
175
+ next(): void;
176
+ goTo(index: number): void;
177
+ get distanceThreshold(): number;
178
+ private onSnap;
179
+ resize(): void;
158
180
  }
159
-
160
- export { type OnSnapCallback, type SnapItem, type SnapOptions, Snap as default };
181
+ //#endregion
182
+ export { OnSnapCallback, SnapItem, SnapOptions, Snap as default };
183
+ //# sourceMappingURL=lenis-snap.d.ts.map