From 38408ecde0712fefa70a8b9920941662e886cba4 Mon Sep 17 00:00:00 2001 From: James Campos Date: Wed, 29 Dec 2010 14:05:49 -0800 Subject: [PATCH] fix slow scrolling --- 4chan_x.coffee | 5 +++-- 4chan_x.js | 11 ++++++++--- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/4chan_x.coffee b/4chan_x.coffee index 02aa96c57..272ff71b1 100644 --- a/4chan_x.coffee +++ b/4chan_x.coffee @@ -1141,11 +1141,12 @@ recaptcha.addEventListener('keydown', recaptchaListener, true) scroll = -> height = document.body.clientHeight - while reply = g.replies[0] + for reply, i in g.replies bottom = reply.getBoundingClientRect().bottom if bottom > height #post is not completely read break - g.replies.shift() + if i is 0 then return + g.replies = g.replies[i..] updateTitle() #major features diff --git a/4chan_x.js b/4chan_x.js index 41f83d800..02497e858 100644 --- a/4chan_x.js +++ b/4chan_x.js @@ -1429,15 +1429,20 @@ recaptcha = $('#recaptcha_response_field'); recaptcha.addEventListener('keydown', recaptchaListener, true); scroll = function() { - var bottom, height, reply; + var bottom, height, i, reply, _len, _ref; height = document.body.clientHeight; - while (reply = g.replies[0]) { + _ref = g.replies; + for (i = 0, _len = _ref.length; i < _len; i++) { + reply = _ref[i]; bottom = reply.getBoundingClientRect().bottom; if (bottom > height) { break; } - g.replies.shift(); } + if (i === 0) { + return; + } + g.replies = g.replies.slice(i); return updateTitle(); }; if (getConfig('Restore IDs')) {