From 6e5e5596fdb8ce68a143c1558844188caedb8dc5 Mon Sep 17 00:00:00 2001 From: Tim Abbott Date: Thu, 30 Jan 2014 18:00:33 -0500 Subject: [PATCH] Remove deferred installation of scroll handler. This is no longer required, now that we're no longer scrolling the main body of the page. (imported from commit c2aa0d403c8fd0679b3110fe8e7684d46a7557fa) --- static/js/ui.js | 12 +++++------- static/js/zulip.js | 37 ------------------------------------- 2 files changed, 5 insertions(+), 44 deletions(-) diff --git a/static/js/ui.js b/static/js/ui.js index 64ef2d8f26..9405aa3f3f 100644 --- a/static/js/ui.js +++ b/static/js/ui.js @@ -1810,18 +1810,16 @@ function scroll_finish() { scroll_timer = setTimeout(scroll_finished, 100); } -exports.register_scroll_handler = function () { - viewport.message_pane.scroll($.throttle(50, function (e) { - process_visible_unread_messages(); - scroll_finish(); - })); -}; - // Save the compose content cursor position and restore when we // shift-tab back in (see hotkey.js). var saved_compose_cursor = 0; $(function () { + viewport.message_pane.scroll($.throttle(50, function (e) { + process_visible_unread_messages(); + scroll_finish(); + })); + $('#new_message_content').blur(function () { saved_compose_cursor = $(this).caret().start; }); diff --git a/static/js/zulip.js b/static/js/zulip.js index e933df83ff..1870263ad2 100644 --- a/static/js/zulip.js +++ b/static/js/zulip.js @@ -37,8 +37,6 @@ var unread_messages_read_in_narrow = false; var pointer_update_in_flight = false; var suppress_unread_counts = true; -var waiting_on_browser_scroll = true; - function within_viewport(row_offset, row_height) { // Returns true if a message is fully within the effectively visible // part of the viewport. @@ -839,12 +837,6 @@ function process_result(messages, opts) { } function get_old_messages_success(data, opts) { - if (waiting_on_browser_scroll) { - setTimeout(function () { - get_old_messages_success(data, opts); - }, 25); - return; - } if (tutorial.is_running()) { // Don't actually process the messages until the tutorial is // finished, but do disable the loading indicator so it isn't @@ -1126,35 +1118,6 @@ function main() { }); } -function install_main_scroll_handler() { - waiting_on_browser_scroll = false; - // Unregister this special un-throttled scroll handler. - $(window).unbind("scroll"); - // Register the normal throttled scroll handler. - ui.register_scroll_handler(); -} - $(function () { - // On a page load or reload, the browser will, at an idle time, scroll to - // the top of the page. We can't intercept this browser-induced scroll, so - // to make sure it doesn't in interfere with our scrolling to the correct - // place in your message feed, we let the browser scroll happen first. - - // After some time, if we haven't seen the browser scroll, give up - // and call main. - var browser_scroll_timer = setTimeout(function () { - install_main_scroll_handler(); - }, 500); - - $(window).scroll(function () { - if (viewport.scrollTop() < viewport.height()) { - // This is the browser-induced scroll to the top of the - // page that we were waiting for. It only happens once, - // so stop waiting and call main. - install_main_scroll_handler(); - clearTimeout(browser_scroll_timer); - } - }); - main(); });