diff options
| author | czaks <marcin@6irc.net> | 2014-01-26 18:23:52 +0100 |
|---|---|---|
| committer | czaks <marcin@6irc.net> | 2014-01-26 18:23:52 +0100 |
| commit | 808a5ab8f6723cfc1eaf32fe7dc32be275c6d045 (patch) | |
| tree | 1f54723a5e2445c3135a85ecaa6ce264786bc53d | |
| parent | 9109096ea861f98059132fbd2664e4d7557cea42 (diff) | |
well, this actually fixes vichan-devel#41 i believe
| -rw-r--r-- | js/watch.js | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/js/watch.js b/js/watch.js index f7795db5..64437f47 100644 --- a/js/watch.js +++ b/js/watch.js @@ -23,6 +23,15 @@ $(function(){ delete localStorage.watch; } + var window_active = true; + $(window).focus(function() { + window_active = true; + $(window).trigger('scroll'); + }); + $(window).blur(function() { + window_active = false; + }); + var status = {}; time_loaded = Date.now(); @@ -225,6 +234,7 @@ $(function(){ }; var fetch_jsons = function() { if (updating_suspended) return; + if (window_active) check_scroll(); var st = storage(); for (var i in st) { @@ -334,7 +344,7 @@ $(function(){ post.position().top + post.height(); } - $(window).scroll(function() { + var check_scroll = function() { if (!status) return; var refresh = false; for(var bid in status) { @@ -356,11 +366,16 @@ $(function(){ } } } + return refresh; + }; + + $(window).scroll(function() { + var refresh = check_scroll(); if (refresh) { fetch_jsons(); refresh = false; } - }).trigger("scroll"); + }); if (typeof add_title_collector != "undefined") add_title_collector(function() { |
