scroll-seamless
Version:
A seamless scroll library for JS, Vue, and React.
80 lines (74 loc) • 2.21 kB
TypeScript
import { ForwardRefExoticComponent, ReactNode, RefAttributes } from 'react';
type ScrollDirection = 'up' | 'down' | 'left' | 'right';
type ScrollSeamlessEvent =
| 'start'
| 'stop'
| 'destroy'
| 'update'
| 'reach-end'
| 'reach-start';
interface PerformancePluginOptions {
enabled?: boolean;
fps?: boolean;
memory?: boolean;
timing?: boolean;
onUpdate?: (metrics: any) => void;
}
interface AccessibilityPluginOptions {
enabled?: boolean;
ariaLabel?: string;
keyboardNavigation?: boolean;
screenReader?: boolean;
focusable?: boolean;
}
interface ScrollSeamlessPlugin {
id: string;
apply: (instance: ScrollSeamlessController) => void;
destroy?: () => void;
}
interface ScrollSeamlessOptions {
data: string[];
direction?: ScrollDirection;
minCountToScroll?: number;
step?: number;
stepWait?: number;
delay?: number;
bezier?: [number, number, number, number];
hoverStop?: boolean;
wheelEnable?: boolean;
singleLine?: boolean;
rows?: number;
cols?: number;
onEvent?: (event: ScrollSeamlessEvent, data?: any) => void;
plugins?: ScrollSeamlessPlugin[];
performance?: PerformancePluginOptions;
accessibility?: AccessibilityPluginOptions;
}
interface ScrollSeamlessController {
start: () => void;
stop: () => void;
destroy: () => void;
updateData: () => void;
setOptions: (options: Partial<ScrollSeamlessOptions>) => void;
isRunning: () => boolean;
getPosition?: () => number;
setPosition?: (position: number) => void;
addPlugin?: (plugin: ScrollSeamlessPlugin) => void;
removePlugin?: (pluginId: string) => void;
getPerformance?: () => any;
}
interface ScrollSeamlessProps extends ScrollSeamlessOptions {
children?: ReactNode;
running?: boolean;
}
interface ScrollSeamlessRef {
start: () => void;
stop: () => void;
destroy: () => void;
updateData: (data: string[]) => void;
setOptions: (options: Partial<ScrollSeamlessOptions>) => void;
isRunning: () => boolean | undefined;
}
declare const ScrollSeamless: ForwardRefExoticComponent<ScrollSeamlessProps & RefAttributes<ScrollSeamlessRef>>;
export { ScrollSeamless as default };
export type { ScrollSeamlessOptions, ScrollSeamlessProps, ScrollSeamlessRef };