-
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathscroller.d.ts
57 lines (43 loc) · 1.53 KB
/
scroller.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
type MilliSecondsCount = number;
type RelativePoint = "start" | "center" | "end";
type ContentAlignment = RelativePoint;
type ScrollDestination = number | `${number}` | RelativePoint;
type ElementVisibility = "hidden" | "visible";
type ComponentRoot = HTMLElement;
interface ScrollerConstructorConfig {
element: ComponentRoot;
/** @default "start" */
align?: ContentAlignment;
/** @default "visible" */
scrollbar?: ElementVisibility;
/** @default "visible" */
navigation?: ElementVisibility;
/** @default "start" */
startPosition?: ScrollDestination;
/**
* Determines the time of the initial position adjustment animation.
* @default 250
*/
startDuration?: MilliSecondsCount;
/**
* Fires when the user clicks on a scroller item
* without dragging the content.
*/
onItemClick?(event: MouseEvent | TouchEvent): void;
/**
* Don't create the component element but use existing layout instead.
* Helpful when creating component wrappers for React, Vue, etc.
* @default false
*/
useExternalLayout?: boolean;
}
type StartSettings = "element" | "useExternalLayout" | "startPosition" | "startDuration";
interface ScrollerUpdateConfig extends Omit<ScrollerConstructorConfig, StartSettings> {}
export interface ScrollerConstructor {
new (config: ScrollerConstructorConfig): ScrollerInstance;
}
export interface ScrollerInstance {
scrollTo(point: ScrollDestination, duration?: MilliSecondsCount): void;
update(config: ScrollerUpdateConfig): void;
}
declare const Scroller: ScrollerConstructor;