If you unnarrow while scrolling, wait for the scroll to finish.

Otherwise you may end up scrolled to a random place.

(imported from commit 99d73b1876e3bde288b14b00bd48b1013f40e268)
This commit is contained in:
Jessica McKellar
2013-07-16 14:00:47 -04:00
parent 68f2991746
commit 4ac64ed6eb
2 changed files with 17 additions and 0 deletions

View File

@@ -509,6 +509,14 @@ exports.deactivate = function () {
return; 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; current_filter = undefined;
exports.hide_empty_narrow_message(); exports.hide_empty_narrow_message();

View File

@@ -2,6 +2,12 @@ var ui = (function () {
var exports = {}; var exports = {};
var actively_scrolling = false;
exports.actively_scrolling = function () {
return actively_scrolling;
};
// What, if anything, obscures the home tab? // What, if anything, obscures the home tab?
exports.home_tab_obscured = function () { exports.home_tab_obscured = function () {
if ($('.modal:visible').length > 0) if ($('.modal:visible').length > 0)
@@ -659,6 +665,8 @@ $(function () {
var scroll_start_message; var scroll_start_message;
function scroll_finished() { function scroll_finished() {
actively_scrolling = false;
if ($('#home').hasClass('active')) { if ($('#home').hasClass('active')) {
if (!suppress_scroll_pointer_update) { if (!suppress_scroll_pointer_update) {
keep_pointer_in_view(); keep_pointer_in_view();
@@ -683,6 +691,7 @@ $(function () {
var scroll_timer; var scroll_timer;
function scroll_finish() { function scroll_finish() {
actively_scrolling = true;
clearTimeout(scroll_timer); clearTimeout(scroll_timer);
scroll_timer = setTimeout(scroll_finished, 100); scroll_timer = setTimeout(scroll_finished, 100);
} }