-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAutoScroller.js
More file actions
55 lines (46 loc) · 1.3 KB
/
AutoScroller.js
File metadata and controls
55 lines (46 loc) · 1.3 KB
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
var AutoScroller = new function () {
this.speed = 1;
this.div = "NOTSET";
//These should be private
var accel = this.speed;
var down = true;
var pause = false;
this.scroll = function () {
if (this.div == "NOTSET") {
alert('Set div to scroll');
return;
}
this.div.scrollTop = this.div.scrollTop + accel;
var timer = 100;
//If scroller hits top or bottom change scroll direction
if (this.div.scrollTop + accel <= 0 || this.div.scrollTop + accel >= (this.div.scrollHeight - this.div.clientHeight)) {
this.changeDirection();
timer = 1500;
}
if (pause == false) {
setTimeout("AutoScroller.scroll()", timer);
}
};
this.scrollDown = function () {
this.div.scrollTop = this.div.scrollTop + 10;
};
this.scrollUp = function () {
this.div.scrollTop = this.div.scrollTop - 10;
};
this.changeDirection = function () {
down = !down;
if (down) {
accel = this.speed;
}
else {
accel = -this.speed;
}
};
this.pauseScroller = function () {
pause = true;
};
this.startScroller = function () {
pause = false;
this.scroll();
};
} ();