Skip to content

Commit

Permalink
cleaner uid
Browse files Browse the repository at this point in the history
  • Loading branch information
clementroche committed Jun 4, 2024
1 parent 717caca commit cb978e2
Show file tree
Hide file tree
Showing 13 changed files with 462 additions and 341 deletions.
82 changes: 66 additions & 16 deletions packages/snap/dist/lenis-snap.d.ts
Original file line number Diff line number Diff line change
@@ -1,30 +1,80 @@
import Lenis from 'lenis';

type SnapElementOptions = {
align?: string[];
ignoreSticky?: boolean;
ignoreTransform?: boolean;
};
type Rect = {
top: number;
left: number;
width: number;
height: number;
x: number;
y: number;
bottom: number;
right: number;
element: HTMLElement;
};
declare class SnapElement {
element: HTMLElement;
options: SnapElementOptions;
rect: Rect;
wrapperResizeObserver: ResizeObserver;
resizeObserver: ResizeObserver;
constructor(element: HTMLElement, { align, ignoreSticky, ignoreTransform, }?: SnapElementOptions);
destroy(): void;
setRect({ top, left, width, height, element, }?: {
top?: number;
left?: number;
width?: number;
height?: number;
element?: HTMLElement;
}): void;
onWrapperResize: () => void;
onResize: ([entry]: ResizeObserverEntry[]) => void;
}

type UID = number;

type Viewport = {
width: number;
height: number;
};
type SnapOptions = {
type?: 'mandatory' | 'proximity';
lerp?: number;
easing?: (t: number) => number;
duration?: number;
velocityThreshold?: number;
onSnapStart?: (t: number) => number;
onSnapComplete?: (t: number) => number;
};
declare class Snap {
constructor(lenis: any, { type, lerp, easing, duration, velocityThreshold, onSnapStart, onSnapComplete, }?: {
type?: string;
lerp: any;
easing: any;
duration: any;
velocityThreshold?: number;
onSnapStart: any;
onSnapComplete: any;
});
lenis: Lenis;
options: SnapOptions;
elements: Map<UID, SnapElement>;
snaps: Map<UID, number>;
viewport: Viewport;
isStopped: Boolean;
constructor(lenis: Lenis, { type, lerp, easing, duration, velocityThreshold, onSnapStart, onSnapComplete, }?: SnapOptions);
destroy(): void;
start(): void;
stop(): void;
add(value: any): () => void;
remove(id: any): void;
addElement(element: any, options?: {}): () => void;
removeElement(id: any): void;
add(value: number): () => void;
remove(id: UID): void;
addElement(element: HTMLElement, options?: SnapElementOptions): () => void;
removeElement(id: UID): void;
onWindowResize: () => void;
onScroll: ({ scroll, limit, lastVelocity, velocity, isScrolling, isTouching, userData, }: {
onScroll: ({ scroll, limit, lastVelocity, velocity, isScrolling, userData, isHorizontal, }: {
scroll: any;
limit: any;
lastVelocity: any;
velocity: any;
isScrolling: any;
isTouching: any;
userData: any;
isHorizontal: any;
}) => void;
}

export { Snap as default };
export { type SnapOptions, Snap as default };
Loading

0 comments on commit cb978e2

Please sign in to comment.