From 0c3ace82d56f3d7b13e2937181d90a800565a92a Mon Sep 17 00:00:00 2001 From: Waseem Daher Date: Fri, 5 Oct 2012 15:35:36 -0400 Subject: [PATCH] Use throttling on our handling of scroll events. This actually is a bit cleaner than our last approach, because (I believe) we run our scroll handler code even after the final scroll event, which prevents the pointer from getting hidden by rapid scrolls. (imported from commit 3bde4e8f067cd2406f90c04425c6e4ffb81ea784) --- templates/zephyr/index.html | 1 + zephyr/static/js/ui.js | 13 ++++--------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/templates/zephyr/index.html b/templates/zephyr/index.html index b6fc3262a7..18212d4587 100644 --- a/templates/zephyr/index.html +++ b/templates/zephyr/index.html @@ -27,6 +27,7 @@ + diff --git a/zephyr/static/js/ui.js b/zephyr/static/js/ui.js index b59ca0860f..ed297e4b9f 100644 --- a/zephyr/static/js/ui.js +++ b/zephyr/static/js/ui.js @@ -124,18 +124,13 @@ $(function () { sub_from_home(compose_class_name(), $('#class-nosub')); }); - var last_mousewheel_or_scroll = 0; - function do_mousewheel_or_scroll () { + var throttled_scrollhandler = $.throttle(50, function() { if ($('#home').hasClass('active')) { - var time = $.now(); - if (time - last_mousewheel_or_scroll > 50) { keep_pointer_in_view(); - last_mousewheel_or_scroll = time; - } } - } - $(window).mousewheel(do_mousewheel_or_scroll); - $(window).scroll(do_mousewheel_or_scroll); + }); + $(window).mousewheel(throttled_scrollhandler); + $(window).scroll(throttled_scrollhandler); $('#sidebar a[data-toggle="pill"]').on('show', function (e) { // Save the position of our old tab away, before we switch