From 858a808fb8d4b6beac415e1273ebcbaaa46fd1d0 Mon Sep 17 00:00:00 2001 From: Malte Ubl Date: Tue, 15 Feb 2011 20:52:45 +0100 Subject: [PATCH] Optimization: Don't draw while the user scrolls --- public/lib/stream/initplugins.js | 9 ++++++++- public/lib/stream/status.js | 3 +++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/public/lib/stream/initplugins.js b/public/lib/stream/initplugins.js index 19bd8c6..8c7f16a 100644 --- a/public/lib/stream/initplugins.js +++ b/public/lib/stream/initplugins.js @@ -49,9 +49,16 @@ require.def("stream/initplugins", win.bind("hashchange", change); // who cares about old browsers? change(); + var scrollTimer; + function scrollTimeout() { + window.Streamie_Just_Scrolled = false; + } win.bind("scroll", function () { plugin.ScrollState[location.hash.replace(/^\#/, "") || "all"] = win.scrollTop(); - }) + window.Streamie_Just_Scrolled = true; + clearTimeout(scrollTimer); + scrollTimer = setTimeout(scrollTimeout, 1000); + }); } }, diff --git a/public/lib/stream/status.js b/public/lib/stream/status.js index 66613b6..005aa55 100644 --- a/public/lib/stream/status.js +++ b/public/lib/stream/status.js @@ -470,6 +470,9 @@ require.def("stream/status", age: { func: function age (tweet) { function update() { + if(window.Streamie_Just_Scrolled) { // never draw while scrolling + return; + } $('#stream').children().each(function() { var tweet = $(this).data('tweet');