From 8472292906fd7bd70ef17ac8015c1faba260fcda Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sat, 4 Aug 2018 02:39:30 -0400 Subject: [PATCH] pointer.js: Add setter for suppress_scroll_pointer_update. After migration to an ES6 module, `suppress_scroll_pointer_update` would no longer be mutable from outside the module. Signed-off-by: Anders Kaseorg --- static/js/message_scroll.js | 2 +- static/js/message_viewport.js | 6 +++--- static/js/pointer.js | 3 +++ static/js/stream_muting.js | 2 +- 4 files changed, 8 insertions(+), 5 deletions(-) diff --git a/static/js/message_scroll.js b/static/js/message_scroll.js index 79cc46c7ce..7bc11abaec 100644 --- a/static/js/message_scroll.js +++ b/static/js/message_scroll.js @@ -39,7 +39,7 @@ exports.scroll_finished = function () { if (!pointer.suppress_scroll_pointer_update) { message_viewport.keep_pointer_in_view(); } else { - pointer.suppress_scroll_pointer_update = false; + pointer.set_suppress_scroll_pointer_update(false); } floating_recipient_bar.update(); diff --git a/static/js/message_viewport.js b/static/js/message_viewport.js index dba3545008..f154d51fa2 100644 --- a/static/js/message_viewport.js +++ b/static/js/message_viewport.js @@ -125,7 +125,7 @@ exports.set_message_position = function (message_top, message_height, viewport_i message_top - message_offset; - pointer.suppress_scroll_pointer_update = true; // Gets set to false in the scroll handler. + pointer.set_suppress_scroll_pointer_update(true); // Gets set to false in the scroll handler. exports.scrollTop(new_scroll_top); }; @@ -282,7 +282,7 @@ exports.is_narrow = function () { }; exports.system_initiated_animate_scroll = function (scroll_amount) { - pointer.suppress_scroll_pointer_update = true; // Gets set to false in the scroll handler. + pointer.set_suppress_scroll_pointer_update(true); // Gets set to false in the scroll handler. var viewport_offset = exports.scrollTop(); in_stoppable_autoscroll = true; exports.message_pane.animate({ @@ -294,7 +294,7 @@ exports.system_initiated_animate_scroll = function (scroll_amount) { }; exports.user_initiated_animate_scroll = function (scroll_amount) { - pointer.suppress_scroll_pointer_update = true; // Gets set to false in the scroll handler. + pointer.set_suppress_scroll_pointer_update(true); // Gets set to false in the scroll handler. in_stoppable_autoscroll = false; // defensive var viewport_offset = exports.scrollTop(); diff --git a/static/js/pointer.js b/static/js/pointer.js index a72aa90bc9..688a80674f 100644 --- a/static/js/pointer.js +++ b/static/js/pointer.js @@ -13,6 +13,9 @@ exports.set_recenter_pointer_on_display = function (value) { // Toggles re-centering the pointer in the window // when All Messages is next clicked by the user exports.suppress_scroll_pointer_update = false; +exports.set_suppress_scroll_pointer_update = function (value) { + exports.suppress_scroll_pointer_update = value; +}; exports.furthest_read = -1; exports.set_furthest_read = function (value) { exports.furthest_read = value; diff --git a/static/js/stream_muting.js b/static/js/stream_muting.js index 2d33f414c6..5fe09677b9 100644 --- a/static/js/stream_muting.js +++ b/static/js/stream_muting.js @@ -39,7 +39,7 @@ exports.update_is_muted = function (sub, value) { // make sure the pointer is still visible. We don't want the auto-scroll handler to move // our pointer to the old scroll location before we have a chance to update it. pointer.set_recenter_pointer_on_display(true); - pointer.suppress_scroll_pointer_update = true; + pointer.set_suppress_scroll_pointer_update(true); if (!home_msg_list.empty()) { message_util.do_unread_count_updates(home_msg_list.all_messages());