From 74762bc9161ed5e17510c077a0942fe5d8baada6 Mon Sep 17 00:00:00 2001 From: James Campos Date: Sun, 31 Jul 2011 12:35:43 -0700 Subject: [PATCH] only scroll focused tabs --- 4chan_x.user.js | 10 +++++++++- script.coffee | 5 ++++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/4chan_x.user.js b/4chan_x.user.js index 399ef7904..1f6cd3e7d 100644 --- a/4chan_x.user.js +++ b/4chan_x.user.js @@ -1555,6 +1555,14 @@ updater = { init: function() { var checkbox, checked, dialog, html, input, name, title, _i, _len, _ref; + if (conf['Scrolling']) { + $.bind(window, 'focus', (function() { + return updater.focus = true; + })); + $.bind(window, 'blur', (function() { + return updater.focus = false; + })); + } html = "
-" + conf['Interval'] + "
"; checkbox = config.updater.checkbox; for (name in checkbox) { @@ -1644,7 +1652,7 @@ while ((reply = replies.pop()) && (reply.id > id)) { arr.push(reply.parentNode.parentNode.parentNode); } - scroll = conf['Scrolling'] && arr.length && (d.body.scrollHeight - d.body.clientHeight - window.scrollY < 20); + scroll = updater.focus && arr.length && (d.body.scrollHeight - d.body.clientHeight - window.scrollY < 20); updater.timer.textContent = '-' + conf['Interval']; if (conf['Verbose']) { updater.count.textContent = '+' + arr.length; diff --git a/script.coffee b/script.coffee index 90d29f708..af298c196 100644 --- a/script.coffee +++ b/script.coffee @@ -1255,6 +1255,9 @@ threadHiding = updater = init: -> + if conf['Scrolling'] + $.bind window, 'focus', (-> updater.focus = true) + $.bind window, 'blur', (-> updater.focus = false) html = "
-#{conf['Interval']}
" {checkbox} = config.updater for name of checkbox @@ -1330,7 +1333,7 @@ updater = while (reply = replies.pop()) and (reply.id > id) arr.push reply.parentNode.parentNode.parentNode #table - scroll = conf['Scrolling'] && arr.length && (d.body.scrollHeight - d.body.clientHeight - window.scrollY < 20) + scroll = updater.focus && arr.length && (d.body.scrollHeight - d.body.clientHeight - window.scrollY < 20) updater.timer.textContent = '-' + conf['Interval'] if conf['Verbose']