diff --git a/zephyr/static/js/narrow.js b/zephyr/static/js/narrow.js index ec0f7ebbf9..73aa3463e4 100644 --- a/zephyr/static/js/narrow.js +++ b/zephyr/static/js/narrow.js @@ -509,6 +509,14 @@ exports.deactivate = function () { return; } + if (ui.actively_scrolling()) { + // There is no way to intercept in-flight scroll events, and they will + // cause you to end up in the wrong place if you are actively scrolling + // on an unnarrow. Wait a bit and try again once the scrolling is over. + setTimeout(exports.deactivate, 50); + return; + } + current_filter = undefined; exports.hide_empty_narrow_message(); diff --git a/zephyr/static/js/ui.js b/zephyr/static/js/ui.js index 3417abb06e..1ace1d105f 100644 --- a/zephyr/static/js/ui.js +++ b/zephyr/static/js/ui.js @@ -2,6 +2,12 @@ var ui = (function () { var exports = {}; +var actively_scrolling = false; + +exports.actively_scrolling = function () { + return actively_scrolling; +}; + // What, if anything, obscures the home tab? exports.home_tab_obscured = function () { if ($('.modal:visible').length > 0) @@ -659,6 +665,8 @@ $(function () { var scroll_start_message; function scroll_finished() { + actively_scrolling = false; + if ($('#home').hasClass('active')) { if (!suppress_scroll_pointer_update) { keep_pointer_in_view(); @@ -683,6 +691,7 @@ $(function () { var scroll_timer; function scroll_finish() { + actively_scrolling = true; clearTimeout(scroll_timer); scroll_timer = setTimeout(scroll_finished, 100); }