aboutsummaryrefslogtreecommitdiff
path: root/assets/js
diff options
context:
space:
mode:
authorMaZderMind2014-11-09 19:43:50 +0100
committerMaZderMind2014-11-09 19:43:50 +0100
commit21cb56374ff92578e447e8aadafb1aba2d56e5e0 (patch)
tree6d4e1a07aea1ebc5407300235bd24e72a2dda14e /assets/js
parented7b993d02eb1210e75eb04d88bdc04634b0891b (diff)
only run program timeline update when program timeline is visible
Diffstat (limited to '')
-rw-r--r--assets/js/lustiges-script.js38
1 files changed, 28 insertions, 10 deletions
diff --git a/assets/js/lustiges-script.js b/assets/js/lustiges-script.js
index d1608f8..6085129 100644
--- a/assets/js/lustiges-script.js
+++ b/assets/js/lustiges-script.js
@@ -46,15 +46,18 @@ $(function() {
$irc.addClass('active');
}).attr('src', $iframe.data('src'));
});
+});
+// programm-timeline
+$(function() {
var
$program = $('.program'),
$now = $program.find('.now'),
scrollLock = false,
rewindTimeout,
- rewindTime = 10000 /* 10 seconds after manual navigation */,
-
- scrollDuration = 500 /* 1/2s animation on the scolling element */;
+ rewindTime = 10000, /* 10 seconds after manual navigation */
+ scrollDuration = 500, /* 1/2s animation on the scolling element */
+ updateTimer = 500; /* update now-pointer placement every 1/2s */
$program.on('mouseenter mouseleave touchstart touchend', function(e) {
if(e.type == 'mouseleave' || e.type == 'touchend') {
@@ -68,7 +71,7 @@ $(function() {
});
// program now-marker & scrolling
- function interval(initial) {
+ function updateProgramView(initial) {console.log('updateProgramView');
var
// offset to the browsers realtime (for simulation
offset = $('.program').data('offset'),
@@ -129,15 +132,30 @@ $(function() {
}
}
- // initial trigger
- interval(true);
- // timed triggers
- setInterval(interval, 500);
+ // when on programs tab
+ var updateInterval;
+ function on() {
+ // initial trigger
+ updateProgramView(true);
+
+ // timed triggers
+ updateInterval = setInterval(updateProgramView, updateTimer);
+ }
+
+ function off() {
+ clearInterval(updateInterval);
+ }
+
+ if(window.location.hash == '#program')
+ on();
// trigger when a tab was changed
- $('.nav-tabs').on('shown.bs.tab', 'a', function (e) {
- interval(true);
+ $('.nav-tabs').on('shown.bs.tab', 'a', function(e) {
+ if(e.target.hash == '#program')
+ on();
+ else
+ off();
});
});