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 <andersk@mit.edu>
This commit is contained in:
Anders Kaseorg 2018-08-04 02:39:30 -04:00 committed by Tim Abbott
parent f9bf414b58
commit 8472292906
4 changed files with 8 additions and 5 deletions

View File

@ -39,7 +39,7 @@ exports.scroll_finished = function () {
if (!pointer.suppress_scroll_pointer_update) { if (!pointer.suppress_scroll_pointer_update) {
message_viewport.keep_pointer_in_view(); message_viewport.keep_pointer_in_view();
} else { } else {
pointer.suppress_scroll_pointer_update = false; pointer.set_suppress_scroll_pointer_update(false);
} }
floating_recipient_bar.update(); floating_recipient_bar.update();

View File

@ -125,7 +125,7 @@ exports.set_message_position = function (message_top, message_height, viewport_i
message_top message_top
- message_offset; - 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); exports.scrollTop(new_scroll_top);
}; };
@ -282,7 +282,7 @@ exports.is_narrow = function () {
}; };
exports.system_initiated_animate_scroll = function (scroll_amount) { 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(); var viewport_offset = exports.scrollTop();
in_stoppable_autoscroll = true; in_stoppable_autoscroll = true;
exports.message_pane.animate({ exports.message_pane.animate({
@ -294,7 +294,7 @@ exports.system_initiated_animate_scroll = function (scroll_amount) {
}; };
exports.user_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 in_stoppable_autoscroll = false; // defensive
var viewport_offset = exports.scrollTop(); var viewport_offset = exports.scrollTop();

View File

@ -13,6 +13,9 @@ exports.set_recenter_pointer_on_display = function (value) {
// Toggles re-centering the pointer in the window // Toggles re-centering the pointer in the window
// when All Messages is next clicked by the user // when All Messages is next clicked by the user
exports.suppress_scroll_pointer_update = false; 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.furthest_read = -1;
exports.set_furthest_read = function (value) { exports.set_furthest_read = function (value) {
exports.furthest_read = value; exports.furthest_read = value;

View File

@ -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 // 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. // our pointer to the old scroll location before we have a chance to update it.
pointer.set_recenter_pointer_on_display(true); 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()) { if (!home_msg_list.empty()) {
message_util.do_unread_count_updates(home_msg_list.all_messages()); message_util.do_unread_count_updates(home_msg_list.all_messages());