Skip to content

Commit

Permalink
Optimization: Don't draw while the user scrolls
Browse files Browse the repository at this point in the history
  • Loading branch information
cramforce committed Feb 15, 2011
1 parent 1f83cd5 commit 858a808
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
9 changes: 8 additions & 1 deletion public/lib/stream/initplugins.js
Expand Up @@ -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);
});
}
},

Expand Down
3 changes: 3 additions & 0 deletions public/lib/stream/status.js
Expand Up @@ -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');

Expand Down

0 comments on commit 858a808

Please sign in to comment.