mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-02-18 06:42:52 +00:00
* Added type definitions for scrollbooster * Added new lines for better readability * Added more info on the project * Extending the correct linter
56 lines
1.4 KiB
TypeScript
56 lines
1.4 KiB
TypeScript
// Type definitions for scrollbooster 2.2
|
|
// Project: https://github.com/ilyashubin/scrollbooster
|
|
// Definitions by: Chris <https://github.com/chrisneven>
|
|
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
|
|
|
export interface Position {
|
|
x?: number;
|
|
y?: number;
|
|
}
|
|
|
|
export interface ScrollingState {
|
|
isMoving: boolean;
|
|
isDragging: boolean;
|
|
position: Required<Position>;
|
|
dragOffset: number;
|
|
borderCollision: {
|
|
left: boolean;
|
|
right: boolean;
|
|
top: boolean;
|
|
bottom: boolean;
|
|
};
|
|
}
|
|
|
|
export interface ScrollBoosterOptions {
|
|
content?: HTMLElement | null;
|
|
viewport: HTMLElement | null;
|
|
scrollMode?: 'transform' | 'native';
|
|
direction?: 'horizontal' | 'vertical' | 'all';
|
|
bounce?: boolean;
|
|
textSelection?: boolean;
|
|
inputsFocus?: boolean;
|
|
pointerMode?: 'touch' | 'mouse' | 'all';
|
|
friction?: number;
|
|
bounceForce?: number;
|
|
emulateScroll?: boolean;
|
|
onUpdate?: (state: ScrollingState) => void;
|
|
onClick?: (state: ScrollingState, event: Event) => void;
|
|
shouldScroll?: (state: ScrollingState, event: Event) => boolean;
|
|
}
|
|
|
|
export default class ScrollBooster {
|
|
constructor(options: ScrollBoosterOptions);
|
|
|
|
setPosition(position: Position): void;
|
|
|
|
scrollTo(position: Position): void;
|
|
|
|
updateMetrics(): void;
|
|
|
|
updateOptions(options: Partial<ScrollBoosterOptions>): void;
|
|
|
|
getState(): ScrollingState;
|
|
|
|
destroy(): void;
|
|
}
|