Created
November 26, 2021 17:06
-
-
Save LeonBaudouin/fe5124d6e57260f8795b75140a15b5bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
declare module 'virtual-scroll' { | |
export type VirtualScrollEvent = { | |
x: number // total distance scrolled on the x axis | |
y: number // total distance scrolled on the y axis | |
deltaX: number // distance scrolled since the last event on the x axis | |
deltaY: number // distance scrolled since the last event on the y axis | |
originalEvent: Event // the native event triggered by the pointer device or keyboard | |
} | |
export type VirtualScrollCallback = (e: VirtualScrollEvent) => void | |
export type Options = { | |
el: HTMLElement // the target element for mobile touch events. Defaults to window. | |
mouseMultiplier: number // General multiplier for all mousewheel (including Firefox). Default to 1. | |
touchMultiplier: number // Mutiply the touch action by this modifier to make scroll faster than finger movement. Defaults to 2. | |
firefoxMultiplier: number // Firefox on Windows needs a boost, since scrolling is very slow. Defaults to 15. | |
keyStep: number // How many pixels to move with each key press. Defaults to 120. | |
preventTouch: boolean // If true, automatically call e.preventDefault on touchMove. Defaults to false. | |
unpreventTouchClass: string // Elements with this class won't preventDefault on touchMove. For instance, useful for a scrolling text inside a VirtualScroll-controled element. Defaults to vs-touchmove-allowed. | |
passive: boolean | undefined // if used, will use passive events declaration for the wheel and touch listeners. Can be true or false. Defaults to undefined. | |
useKeyboard: boolean // if true, allows to use arrows to navigate, and space to jump from one screen. Defaults to true | |
useTouch: boolean // if true, uses touch events to simulate scrolling. Defaults to true | |
} | |
export default class VirtualScroll { | |
constructor(options?: Partial<Options>) | |
destroy(): void | |
on(cb: VirtualScrollCallback): void | |
off(cb: VirtualScrollCallback): void | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment