forked from happyworm/PerceptiveMedia
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathautoadvance.js
More file actions
33 lines (27 loc) · 860 Bytes
/
autoadvance.js
File metadata and controls
33 lines (27 loc) · 860 Bytes
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
autoAdvanceTimeout = null;
autoAdvanceDuration = 10000;
autoAdvance = function() {
if(w3c_slidy.slide_number < w3c_slidy.slides.length - 1) {
w3c_slidy.next_slide(true);
} else {
w3c_slidy.first_slide();
}
autoAdvanceTimeout = setTimeout(autoAdvance, autoAdvanceDuration);
return w3c_slidy.cancel(event);
};
disableAutoAdvance = function() {
if(autoAdvanceTimeout) clearTimeout(autoAdvanceTimeout);
autoAdvanceTimeout = null;
};
enableAutoAdvance = function(duration) {
if(duration) autoAdvanceDuration = duration;
autoAdvanceTimeout = setTimeout(autoAdvance, autoAdvanceDuration);
};
onAutoAdvanceKeyPress = function(event) {
// disable on any keypress (reload to restart autoAdvance)
if(autoAdvanceTimeout) {
disableAutoAdvanceTimeout();
}
}
document.addEventListener("keypress", onAutoAdvanceKeyPress, false);
//enableAutoAdvance();