-
Notifications
You must be signed in to change notification settings - Fork 0
/
Scroller.js
90 lines (79 loc) · 2.22 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
var pixelIncrement = 2;
var scrollMillisecond = 50;
var refreshScrollWait = 3000;
var scrolled;
function Scroller()
{
var scrollers = new Array();
scrolled = new Array();
var scroll;
var qualifier = 'scroll';
var counter = 0;
scroll = document.getElementById('scroll0');
while (scroll != null)
{
scroll.scrollTop = 0;
scrollers[counter] = qualifier + counter;
scrolled[counter] = false;
counter++;
scroll = document.getElementById(qualifier + counter);
}
scroll = document.getElementById('NRESpace');
if (scroll != null)
{
scroll.scrollTop = 0;
scrollers[counter] = 'NRESpace';
scrolled[counter] = false;
}
if (scrollers.length > 0)
{
setTimeout(function(){Scroll(scrollers)},refreshScrollWait);
}
}
function Scroll(scrollers)
{
var pause = false;
var loop = true;
var scroll;
for (i=0; i < scrollers.length; i++)
{
scroll = document.getElementById(scrollers[i]);
if (scroll != null)
{
if (scroll.scrollHeight > (scroll.scrollTop + scroll.offsetHeight))
{
scroll.scrollTop += pixelIncrement;
if (scroll.scrollTop % scroll.offsetHeight == 0)
{
pause = true;
}
}
if (scroll.scrollTop == 0 || (scroll.scrollTop >= (scroll.scrollHeight - scroll.offsetHeight)))
{
scrolled[i] = true;
}
}
}
for (i=0; i < scrolled.length; i++)
{
if (!scrolled[i])
{
loop = false;
}
}
if (!loop)
{
if (pause)
{
setTimeout(function(){Scroll(scrollers)},refreshScrollWait);
}
else
{
setTimeout(function(){Scroll(scrollers)},scrollMillisecond);
}
}
else
{
setTimeout(function(){Scroller()},refreshScrollWait);
}
}