Debian Codegraph @

src/indicator/_initIndicators.js

raw symbols SCIP
1
2 _initIndicators: function () {
3 var interactive = this.options.interactiveScrollbars,
4 customStyle = typeof this.options.scrollbars != 'string',
5 indicators = [],
6 indicator;
7
8 var that = this;
9
10 this.indicators = [];
11
12 if ( this.options.scrollbars ) {
13 // Vertical scrollbar
14 if ( this.options.scrollY ) {
15 indicator = {
16 el: createDefaultScrollbar('v', interactive, this.options.scrollbars),
17 interactive: interactive,
18 defaultScrollbars: true,
19 customStyle: customStyle,
20 resize: this.options.resizeScrollbars,
21 shrink: this.options.shrinkScrollbars,
22 fade: this.options.fadeScrollbars,
23 listenX: false
24 };
25
26 this.wrapper.appendChild(indicator.el);
27 indicators.push(indicator);
28 }
29
30 // Horizontal scrollbar
31 if ( this.options.scrollX ) {
32 indicator = {
33 el: createDefaultScrollbar('h', interactive, this.options.scrollbars),
34 interactive: interactive,
35 defaultScrollbars: true,
36 customStyle: customStyle,
37 resize: this.options.resizeScrollbars,
38 shrink: this.options.shrinkScrollbars,
39 fade: this.options.fadeScrollbars,
40 listenY: false
41 };
42
43 this.wrapper.appendChild(indicator.el);
44 indicators.push(indicator);
45 }
46 }
47
48 if ( this.options.indicators ) {
49 // TODO: check concat compatibility
50 indicators = indicators.concat(this.options.indicators);
51 }
52
53 for ( var i = indicators.length; i--; ) {
54 this.indicators.push( new Indicator(this, indicators[i]) );
55 }
56
57 // TODO: check if we can use array.map (wide compatibility and performance issues)
58 function _indicatorsMap (fn) {
59 if (that.indicators) {
60 for ( var i = that.indicators.length; i--; ) {
61 fn.call(that.indicators[i]);
62 }
63 }
64 }
65
66 if ( this.options.fadeScrollbars ) {
67 this.on('scrollEnd', function () {
68 _indicatorsMap(function () {
69 this.fade();
70 });
71 });
72
73 this.on('scrollCancel', function () {
74 _indicatorsMap(function () {
75 this.fade();
76 });
77 });
78
79 this.on('scrollStart', function () {
80 _indicatorsMap(function () {
81 this.fade(1);
82 });
83 });
84
85 this.on('beforeScrollStart', function () {
86 _indicatorsMap(function () {
87 this.fade(1, true);
88 });
89 });
90 }
91
92
93 this.on('refresh', function () {
94 _indicatorsMap(function () {
95 this.refresh();
96 });
97 });
98
99 this.on('destroy', function () {
100 _indicatorsMap(function () {
101 this.destroy();
102 });
103
104 delete this.indicators;
105 });
106 },