-
Notifications
You must be signed in to change notification settings - Fork 28
/
Copy pathscroller.js
692 lines (628 loc) · 21.7 KB
/
scroller.js
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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
/*
* Copyright (c) 2014-2015, Pi Ke, All rights reserved
*
* This is a free software
*
* Author : Pi Ke
* Description : A number scroller module to be embedded in your web apps
* Website : http://www.pixelstech.net
*/
;(function(parent){
var Util = {
/* Implement the inheritance logic to make it true OOP*/
extend:function(sup, sub){
sub.prototype = Object.create(sup.prototype);
sub.prototype.constructor = sup;
return sub;
},
/* Clone an object. It is a shallow clone */
clone:function(obj) {
if (null == obj || "object" != typeof obj) return obj;
var copy = obj.constructor();
for (var attr in obj) {
if (obj.hasOwnProperty(attr)) copy[attr] = obj[attr];
}
return copy;
}
};
// Define ScrollPanel super class
function ScrollPanel(props){
this.fragment=null;
this.div=null;
this.innerDdiv=null;
this.direction=props.direction||null;
this.interval=props.interval||0;
this.amount=props.amount||0;
this.width=props.width||0;
this.height=props.amount||0;
this.textAlign=props.textAlign||"center";
this.upperBound=props.upperBound||9;
this.forceFallback=props.forceFallback || false;
this.mode=props._mode||Scroller.MODE.COUNTUP;
// Private variables
this.stepSize=Math.ceil((this.amount+1)*1.0/10) || 2;
this.stepInterval=0;
this.step=1;
this.startNum=1;
this.endNum=1;
this.nextNum=1;
this.firstChild = null;
this.lastChild = null;
this.count = 0;
}
ScrollPanel.prototype=(function(){
return {
init:function(){
this.fragment = document.createDocumentFragment();
this.div = document.createElement("div");
this.div.className = "scroller";
this.div.setAttribute("style","position:relative;overflow:hidden;width:"+this.width+"px;text-align:"+this.textAlign+";height:"+(this.height)+"px;line-height:"+this.height+"px;");
this.innerDiv = document.createElement("div");
this.innerDiv.className = "scroller-inner-pane";
this.innerDiv.setAttribute("style","position:absolute;width:"+this.width+"px;text-align:"+this.textAlign+";top:0;");
// Create the first child
this.firstChild = document.createElement("span");
this.firstChild.className = "scroller-span";
this.firstChild.setAttribute("style","position:absolute;height:"+this.height+"px;line-height:"+this.height+"px;left:0px;top:0px;width:"+this.width+"px;");
this.innerDiv.appendChild(this.firstChild);
// Create the last child
this.lastChild = document.createElement("span");
this.lastChild.className = "scroller-span";
this.lastChild.setAttribute("style", "position:absolute;height:"+this.height+"px;line-height:"+this.height+"px;left:0px;width:"+this.width+"px;");
switch(this.direction){
case Scroller.DIRECTION.UP : this.innerDiv.appendChild(this.lastChild);
this.lastChild.style.top = this.height + "px";
break;
case Scroller.DIRECTION.DOWN : this.innerDiv.insertBefore(this.lastChild, this.firstChild);
this.lastChild.style.top = (-this.height) + "px";
break;
}
this.div.appendChild(this.innerDiv);
this.fragment.appendChild(this.div);
this.innerInit();
return this;
},
innerInit:function(){/* To be implemented by subclasses */},
start:function(start, end){
start = parseInt(start);
end = parseInt(end);
this.startNum = start;
this.endNum = end;
this.nextNum = this.startNum;
if(this.mode == Scroller.MODE.COUNTDOWN){
if(start!=end){
this.step = (this.endNum>this.startNum)?(this.startNum+(this.upperBound+1)-this.endNum):(this.startNum-this.endNum);
}else{
this.step = Number.MAX_VALUE;
}
} else {
if(start!=end){
this.step = (this.endNum<this.startNum)?(this.endNum+(this.upperBound+1)-this.startNum):(this.endNum-this.startNum);
}else{
this.step = Number.MAX_VALUE;
}
}
this.firstChild.innerHTML = this.startNum;
this.lastChild.innerHTML = this.nextNum;
this.innerStart();
// Iterate the counter numbers
this.iterate();
},
innerStart:function(){/* To be implemented by subclasses */},
iterate:function(){
if(this.nextNum != this.endNum || this.lastChild.innerHTML != this.endNum){
// Below check is to ensure the UI is updated properly.
// Sometimes when in low memory situation the nextNum
// has been set to endNum, but the corresponding UI is
// not updated to the endNum
if(this.nextNum == this.endNum){
this.nextNum = parseInt(this.lastChild.innerHTML);
}
if(this.mode == Scroller.MODE.COUNTDOWN){
this.nextNum = (this.nextNum == 0)?this.upperBound:(this.nextNum-1);
} else {
this.nextNum = (this.nextNum == this.upperBound)?0:(this.nextNum+1);
}
this.innerIterate();
}
},
innerIterate:function(){/* To be implemented by subclasses */},
scroll:function(){/* To be implemented by subclasses */},
stop:function(){/* To be implemented by subclasses */},
revalidate:function(){
this.nextNum = parseInt(this.nextNum);
this.endNum = parseInt(this.endNum);
// If next number is the same as end number, do nothing
if(this.nextNum == this.endNum){
return;
}
if(this.mode == Scroller.MODE.COUNTDOWN){
if(this.nextNum!=this.endNum){
this.step = (this.endNum>this.nextNum)?(this.nextNum+(this.upperBound+1)-this.endNum):(this.nextNum-this.endNum);
}else{
this.step = Number.MAX_VALUE;
}
} else {
if(this.nextNum!=this.endNum){
this.step=(this.endNum<this.nextNum)?(this.endNum+(this.upperBound+1)-this.nextNum):(this.endNum-this.nextNum);
}else{
this.step = Number.MAX_VALUE;
}
}
this.innerRevalidate();
},
innerRevalidate:function(){/* To be implemented by subclasses */},
resetPosition:function(){
this.innerDiv.style.top = "0px";
this.innerDiv.offsetHeight;
},
getPanel:function(){
return this.fragment;
},
setEndNum:function(endNumber){
this.endNum=endNumber;
},
setMode:function(mode){
this.mode=mode;
}
};
})();
// Create subclass CSSTransitionScrollPanel
function CSSTransitionScrollPanel(props){
ScrollPanel.call(this, props);
}
Util.extend(ScrollPanel, CSSTransitionScrollPanel);
CSSTransitionScrollPanel.prototype._props = {};
CSSTransitionScrollPanel.prototype._cssPropMap = {
"transition-timing-function" : "TransitionTimingFunction",
"transition-duration" : "TransitionDuration",
"transform" : "Transform"
};
CSSTransitionScrollPanel.prototype._set=function(obj, type, value){
if(this._props[type]){
obj.style.setProperty(this._props[type], value, "important");
}else{
var modes = "-webkit- -moz- -ms- -o-".split(" ");
CSSTransitionScrollPanel.prototype._props[type] = type;
for(var i=0, len = modes.length; i<len; ++i){
var mode = modes[i].replace(/-/g,"");
mode = (mode == "moz") ? "Moz" : mode;
var jsStyleProp = mode+CSSTransitionScrollPanel.prototype._cssPropMap[type];
if(obj.style[jsStyleProp] !== undefined){
CSSTransitionScrollPanel.prototype._props[type] = modes[i]+type;
break;
}
}
this._set(obj, type, value);
}
}
// Add event listener to each scroll pane
CSSTransitionScrollPanel.prototype._addEventListener=function(obj, that){
var transitions = {
'WebkitTransition' : 'webkitTransitionEnd',
'MozTransition' : 'transitionend',
'MSTransition' : 'msTransitionEnd',
'OTransition' : 'oTransitionEnd',
'transition' : 'transitionend'
};
for(var t in transitions){
if(obj.style[t] !== undefined){
obj.addEventListener(transitions[t], function(event){
var transitionDuration = obj.style.transitionDuration || obj.style.webkitTransitionDuration;
if(transitionDuration != "0ms"){
that.stop();
}
}, false);
break;
}
}
}
CSSTransitionScrollPanel.prototype.innerInit = function(){
this._addEventListener(this.innerDiv, this);
this._set(this.innerDiv, "transition-timing-function", "linear");
};
CSSTransitionScrollPanel.prototype.innerStart = function(){
this.stepInterval=Math.max(1, Math.floor(this.interval*1.0/this.step));
if(this.direction == Scroller.DIRECTION.UP){
this.amount = -this.amount;
}
};
CSSTransitionScrollPanel.prototype.innerIterate = function(){
// Swap first and last child
this.firstChild.innerHTML = this.lastChild.innerHTML;
this.lastChild.innerHTML = this.nextNum;
// Ensure UI repaint
this.lastChild.offsetHeight;
var that = this;
setTimeout(function(){that.scroll();},0);
};
CSSTransitionScrollPanel.prototype.scroll = function(){
var rand = 1.0 +(Math.random()/100000); // This ensures "transitionend" event will always
// be fired when applied to transform.scaleY().
var transformProperty = "translateY("+this.amount+"px) scaleX("+rand+")";
var durationProperty = (this.stepInterval)+"ms";
this._set(this.innerDiv, "transition-duration", durationProperty);
this._set(this.innerDiv, "transform", transformProperty);
};
CSSTransitionScrollPanel.prototype.stop = function(){
var rand = 1.0 +(Math.random()/100000);
var transformProperty = "translateY(0px) scaleX("+rand+")";
var durationProperty = "0ms";
this.firstChild.innerHTML = this.lastChild.innerHTML;
// Ensure UI repaint
this.lastChild.offsetHeight;
// Sometimes when in low memory situation the nextNum
// has been set to endNum, but the corresponding UI is
// not updated to the endNum
this.nextNum = parseInt(this.lastChild.innerHTML);
this._set(this.innerDiv,"transition-duration", durationProperty);
this._set(this.innerDiv,"transform", transformProperty);
// Here cannot use transitionend event is because the
// transition duration is set to 0ms which may not trigger
// the transitionend event in some browsers.
// Initially the transition duration was set to 1ms so that
// we can rely on the transitionend event to trigger next
// iteration. But the scroll pane will have some flashing
// effects which is not what we expected.
// One disadvantage of this approach is that it has some
// jump ship effects as it doesn't wait the transition to
// completes to trigger next iteration.
var that = this;
setTimeout(function(){
that.iterate();
}, 1);
};
CSSTransitionScrollPanel.prototype.innerRevalidate = function(){
this.stepInterval=Math.max(1, Math.floor(this.interval*1.0/this.step));
};
// Create subclass DOMScrollPanel
function DOMScrollPanel(props){
ScrollPanel.call(this, props);
this.scrolledAmount=0;
this.scrollID=null;
}
Util.extend(ScrollPanel, DOMScrollPanel);
DOMScrollPanel.prototype.innerStart = function(){
this.stepInterval=Math.ceil((this.interval*this.stepSize)/(this.amount*this.step));
};
DOMScrollPanel.prototype.innerIterate = function(){
// Swap first and last child
this.firstChild.innerHTML = this.lastChild.innerHTML;
this.lastChild.innerHTML = this.nextNum;
// Ensure UI repaint
this.lastChild.offsetHeight;
this.scroll();
};
DOMScrollPanel.prototype.scroll = function(){
var innerDivStyle = this.innerDiv.style;
var top = parseInt(innerDivStyle.top);
switch(this.direction){
case Scroller.DIRECTION.UP : innerDivStyle.top = (top - this.stepSize) + "px";
break;
case Scroller.DIRECTION.DOWN : innerDivStyle.top = (top + this.stepSize) + "px";
break;
default:break;
}
this.scrolledAmount+=this.stepSize;
if(this.scrolledAmount < this.amount){
// Below is ensure that the last scroll will not overflow
this.stepSize = Math.min(this.stepSize, (this.amount - this.scrolledAmount));
var that = this;
this.scrollID = setTimeout(function(){that.scroll();},this.stepInterval);
}else{
if(this.scrollID!=null){
clearTimeout(this.scrollID);
}
this.stop();
this.iterate();
}
};
DOMScrollPanel.prototype.stop = function(){
this.scrolledAmount = 0;
this.firstChild.innerHTML = this.lastChild.innerHTML;
this.resetPosition();
};
DOMScrollPanel.prototype.innerRevalidate = function(){
this.stepInterval=Math.ceil((this.interval*this.stepSize)/(this.amount*this.step));
};
// ScrollPanelFactory to create ScrollPanels
var ScrollPanelFactory = (function(){
var _isTransformSupported = _detectTransformSupport("transform");
// Check whether CSS3 transform is supported. This is a one time check
// performed above.
function _detectTransformSupport(featureName){
var isSupported = false,
domPrefixes = 'Webkit Moz ms O Khtml'.split(' '),
elm = document.createElement('div'),
featureNameCapital = null;
featureName = featureName.toLowerCase();
if(elm.style[featureName] !== undefined ) { isSupported = true; }
if(isSupported === false){
featureNameCapital = featureName.charAt(0).toUpperCase() + featureName.substr(1);
for( var i = 0; i < domPrefixes.length; i++ ) {
if(elm.style[domPrefixes[i] + featureNameCapital ] !== undefined ) {
isSupported = true;
break;
}
}
}
return isSupported;
}
return {
createScrollPanel : function(props){
if(_isTransformSupported && !props.forceFallback){
return new CSSTransitionScrollPanel(props);
}else{
return new DOMScrollPanel(props);
}
}
};
})();
var Scroller=(function(){
// Watch how many Scroller instances created.
// Just for statistic purpose
var numOfComponent=0;
function ScrollerImpl(props){
this.scrollPanelArray=[];
this.props=props;
this.scrollPane=document.createElement("div");
this.table=null;
this.beginNum=0;
this.endNum=0;
this.css=null;
this.width=this.props.width;
this.init(0,0);
}
ScrollerImpl.prototype={
init:function(begin,end){
this.clear();
this.oldCountArray=[];
this.newCountArray=[];
this.scrollPanelArray=[];
this.beginNum=begin;
this.endNum=end;
begin=begin+"";
end=end+"";
var beginLength=begin.length,endLength=end.length;
for(var i=0;i<beginLength;++i){
this.oldCountArray.push(begin.charAt(i));
}
for(var i=0;i<endLength;++i){
this.newCountArray.push(end.charAt(i));
}
// Do necessary padding
var diff=Math.abs(beginLength-endLength);
var maxLength=Math.max(beginLength,endLength);
if(beginLength>endLength){
for(var i=1;i<=diff;++i){
this.newCountArray.unshift("0");
}
}else if(beginLength<endLength){
for(var i=1;i<=diff;++i){
this.oldCountArray.unshift("0");
}
}
// Start building UI
var divFragment=document.createDocumentFragment();
this.table=document.createElement("table");
this.table.className="scroller-table";
this.table.setAttribute("style","margin:auto;");
if(this.css!=null){
this.setStyle(this.css);
}
var indWidth=Math.floor(this.width/maxLength);
this.props._mode=(this.beginNum>this.endNum)?Scroller.MODE.COUNTDOWN:Scroller.MODE.COUNTUP;
this.props.width = indWidth; //Set the width property
this.innerInit(maxLength);
divFragment.appendChild(this.table);
this.scrollPane.appendChild(divFragment);
for(var i=0,len=this.oldCountArray.length;i<len;++i){
this.scrollPanelArray[i].start(this.oldCountArray[i],this.oldCountArray[i]);
}
},
innerInit:function(maxLength){
var separatorCount=0;
if(this.props.separatorType!==Scroller.SEPARATOR.NONE){
separatorCount = this.props.separatorType+1-maxLength%(this.props.separatorType);
}
var tr=document.createElement("tr");
for(var i=0;i<maxLength;++i){
var td=document.createElement("td");
// Update props
var scrollPanel=ScrollPanelFactory.createScrollPanel(this.props).init();
this.scrollPanelArray.push(scrollPanel);
td.appendChild(scrollPanel.getPanel());
tr.appendChild(td);
if(this.props.separatorType!=Scroller.SEPARATOR.NONE&&
(i+separatorCount)%this.props.separatorType===0&&(i+1)<maxLength){
var td=document.createElement("td");
var div = document.createElement("div");
div.className = "scroller-separator-pane";
var span=document.createElement("span");
span.className="scroller-span";
span.innerHTML=this.props.separator;
div.setAttribute("style","height:"+(this.props.amount + 10)+"px;line-height:"+this.props.amount+"px;left:0px;top:0px;vertical-align:middle;");
div.appendChild(span);
td.appendChild(div);
tr.appendChild(td);
}
}
this.table.appendChild(tr);
},
appendTo:function(parent){
parent.appendChild(this.scrollPane);
return this;
},
getScrollPanels:function(){
return this.scrollPanelArray;
},
// Here style should be JavaScript format
setStyle:function(css){
this.css=css;
if(typeof css === "string"){
var entries = css.split(";");
for(var i in entries){
var pair=entries[i].split(":");
var key=pair[0];
var value=(pair.length==2)?pair[1]:"";
if(!this.isUnmodifiableStyle(key)){
this.table.style[key]=value;
}
}
}else if(typeof css === "object"){
for(var prop in css){
this.table.style[prop]=css[prop];
}
}
// Else silently ignore the css
},
isUnmodifiableStyle:function(propName){
var unmodifiableAttributeNames=["position","overflow"];
for(var i in unmodifiableAttributeNames){
if(propName.toLowerCase()===unmodifiableAttributeNames[i]){
return true;
}
}
return false;
},
start:function(number){
var count=0;
if(typeof number === "number"){
count=parseInt(number)+"";
}else{
count=number.trim().replace(/,/g,"");
}
this.init(number,number);
},
scrollTo:function(number){
var count=(number+"").trim().replace(/,:/g,"");
if(count.length!=this.newCountArray.length){
this.init(this.endNum, count);
}else{
this.beginNum=this.endNum;
this.oldCountArray=this.newCountArray;
this.endNum=count;
this.newCountArray=[];
this.props._mode=(this.beginNum>this.endNum)?Scroller.MODE.COUNTDOWN:Scroller.MODE.COUNTUP;
for(var i=0,len=count.length;i<len;++i){
this.newCountArray.push(count.charAt(i));
}
}
this.refresh();
},
scrollFromTo:function(from,to){
var from=(from+"").trim().replace(/,:/g,"");
var to = (to+"").trim().replace(/,:/g,"");
this.start(from);
this.scrollTo(to);
},
refresh:function(){
var that = this;
setTimeout(function(){
for(var i=0,len=that.oldCountArray.length;i<len;++i){
if(that.props._mode !== undefined){
that.scrollPanelArray[i].setMode(that.props._mode);
}
that.scrollPanelArray[i].setEndNum(that.newCountArray[i]);
that.scrollPanelArray[i].revalidate();
that.scrollPanelArray[i].iterate();
}
},1);
},
clear:function(){
while (this.scrollPane.firstChild) {
this.scrollPane.removeChild(this.scrollPane.firstChild);
}
}
};
// Time ScrollerImpl to extend the ScrollerImpl
function TimeScrollerImpl(props){
ScrollerImpl.call(this, props);
}
Util.extend(ScrollerImpl, TimeScrollerImpl);
TimeScrollerImpl.prototype.innerInit = function(maxLength){
var separatorCount = this.props.separatorType+1-maxLength%(this.props.separatorType);
var tr=document.createElement("tr");
for(var i=0;i<maxLength;++i){
var td=document.createElement("td");
var props = Util.clone(this.props);
if(i%2==0){
if(i==0){
props.upperBound = 2;
}else{
props.upperBound = 5;
}
}
// Update props
var scrollPanel=ScrollPanelFactory.createScrollPanel(props).init();
this.scrollPanelArray.push(scrollPanel);
td.appendChild(scrollPanel.getPanel());
tr.appendChild(td);
if((i+separatorCount)%props.separatorType===0&&(i+1)<maxLength){
var td=document.createElement("td");
var div = document.createElement("div");
var span=document.createElement("span");
span.className="scroller-span";
span.innerHTML=props.separator;
div.setAttribute("style","height:"+(props.amount + 10)+"px;line-height:"+props.amount+"px;left:0px;top:0px;vertical-align:middle;");
div.appendChild(span);
td.appendChild(div);
tr.appendChild(td);
}
}
this.table.appendChild(tr);
};
// ScrollerImplFactory to create different ScrollerImpl
var ScrollerImplFactory = (function(){
return {
createScrollerImpl:function(props){
var obj = null;
switch(props.separatorType){
case Scroller.SEPARATOR.TIME :
obj = new TimeScrollerImpl(props);
break;
case Scroller.SEPARATOR.THOUSAND:
default :
obj = new ScrollerImpl(props);
break;
}
return obj;
}
};
})();
return {
DIRECTION:{
UP : 1,
DOWN : 2
},
SEPARATOR:{
NONE : 0,
TIME : 2,
THOUSAND : 3
},
MODE:{
COUNTUP : 0,
COUNTDOWN : 1
},
getNewInstance:function(props){
numOfComponent++;
// Sanitize properties
props = props || {};
props.direction = props.direction || Scroller.DIRECTION.UP;
props.interval = props.interval || 5000;
props.width = props.width || 400;
props.amount = props.amount || 250;
props.separatorType = props.separatorType || Scroller.SEPARATOR.NONE;
props.separator = props.separator || "";
props.textAlign = props.textAlign || "center";
props.forceFallback = props.forceFallback || false;
return ScrollerImplFactory.createScrollerImpl(props);
},
getScrollerSize:function(){
return numOfComponent;
}
};
})();
// Export the Scroller object
parent.Scroller=Scroller;
})(window);