forked from idiotWu/smooth-scrollbar
-
Notifications
You must be signed in to change notification settings - Fork 0
/
options.ts
73 lines (61 loc) · 1.6 KB
/
options.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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
import {
range,
boolean,
} from './decorators/';
import {
ScrollbarOptions,
} from './interfaces/';
export class Options {
/**
* Momentum reduction damping factor, a float value between `(0, 1)`.
* The lower the value is, the more smooth the scrolling will be
* (also the more paint frames).
*/
@range(0, 1)
damping = 0.1;
/**
* Minimal size for scrollbar thumbs.
*/
@range(0, Infinity)
thumbMinSize = 20;
/**
* Render every frame in integer pixel values
* set to `true` to improve scrolling performance.
*/
@boolean
renderByPixels = true;
/**
* Keep scrollbar tracks visible
*/
@boolean
alwaysShowTracks = false;
/**
* Set to `true` to allow outer scrollbars continue scrolling
* when current scrollbar reaches edge.
*/
@boolean
continuousScrolling = true;
/**
* Delegate wheel events and touch events to the given element.
* By default, the container element is used.
* This option will be useful for dealing with fixed elements.
*/
delegateTo: EventTarget | null = null;
get wheelEventTarget() {
return this.delegateTo;
}
set wheelEventTarget(el: EventTarget | null) {
console.warn('[smooth-scrollbar]: `options.wheelEventTarget` is deprecated and will be removed in the future, use `options.delegateTo` instead.');
this.delegateTo = el;
}
/**
* Options for plugins. Syntax:
* plugins[pluginName] = pluginOptions: any
*/
readonly plugins: any = {};
constructor(config: Partial<ScrollbarOptions> = {}) {
Object.keys(config).forEach((prop) => {
this[prop] = config[prop];
});
}
}