Elffuss BraidHub

kikocis/iscroll public

05f2dd0b824b · 1.7 KiBRawPermalink
1
2 _initIndicators: function () {
3 var interactive = this.options.interactiveScrollbars,
4 defaultScrollbars = typeof this.options.scrollbars != 'object',
5 customStyle = typeof this.options.scrollbars != 'string',
6 indicators = [],
7 indicator;
8
9 this.indicators = [];
10
11 if ( this.options.scrollbars ) {
12 // Vertical scrollbar
13 if ( this.options.scrollY ) {
14 indicator = {
15 el: createDefaultScrollbar('v', interactive, this.options.scrollbars),
16 interactive: interactive,
17 defaultScrollbars: true,
18 customStyle: customStyle,
19 resize: this.options.resizeIndicator,
20 listenX: false
21 };
22
23 this.wrapper.appendChild(indicator.el);
24 indicators.push(indicator);
25 }
26
27 // Horizontal scrollbar
28 if ( this.options.scrollX ) {
29 indicator = {
30 el: createDefaultScrollbar('h', interactive, this.options.scrollbars),
31 interactive: interactive,
32 defaultScrollbars: true,
33 customStyle: customStyle,
34 resize: this.options.resizeIndicator,
35 listenY: false
36 };
37
38 this.wrapper.appendChild(indicator.el);
39 indicators.push(indicator);
40 }
41 }
42
43 if ( this.options.indicators ) {
44 // works fine for arrays and non-arrays
45 indicators = indicators.concat(this.options.indicators);
46 }
47
48 for ( var i = indicators.length; i--; ) {
49 this.indicators[i] = new Indicator(this, indicators[i]);
50 }
51
52 this.on('refresh', function () {
53 if ( this.indicators ) {
54 for ( var i = this.indicators.length; i--; ) {
55 this.indicators[i].refresh();
56 }
57 }
58 });
59
60 this.on('destroy', function () {
61 if ( this.indicators ) {
62 for ( var i = this.indicators.length; i--; ) {
63 this.indicators[i].destroy();
64 }
65 }
66
67 delete this.indicators;
68 });
69 },