From 6e4ae95994944a6afffae70e3f087cf055fca5f9 Mon Sep 17 00:00:00 2001 From: Anders Kaseorg Date: Sat, 4 Aug 2018 02:33:00 -0400 Subject: [PATCH] message_viewport.js: Add setter for last_movement_direction. After migration to an ES6 module, `last_movement_direction` would no longer be mutable from outside the module. Signed-off-by: Anders Kaseorg --- static/js/message_viewport.js | 3 +++ static/js/navigate.js | 8 ++++---- static/js/ui_init.js | 2 +- 3 files changed, 8 insertions(+), 5 deletions(-) diff --git a/static/js/message_viewport.js b/static/js/message_viewport.js index 9543954d0a..dba3545008 100644 --- a/static/js/message_viewport.js +++ b/static/js/message_viewport.js @@ -9,6 +9,9 @@ var in_stoppable_autoscroll = false; // Includes both scroll and arrow events. Negative means scroll up, // positive means scroll down. exports.last_movement_direction = 1; +exports.set_last_movement_direction = function (value) { + exports.last_movement_direction = value; +}; exports.at_top = function () { return exports.scrollTop() <= 0; diff --git a/static/js/navigate.js b/static/js/navigate.js index 90290918ef..db70d0ac5e 100644 --- a/static/js/navigate.js +++ b/static/js/navigate.js @@ -10,7 +10,7 @@ function go_to_row(msg_id) { } exports.up = function () { - message_viewport.last_movement_direction = -1; + message_viewport.set_last_movement_direction(-1); var msg_id = current_msg_list.prev(); if (msg_id === undefined) { return; @@ -19,7 +19,7 @@ exports.up = function () { }; exports.down = function (with_centering) { - message_viewport.last_movement_direction = 1; + message_viewport.set_last_movement_direction(1); if (current_msg_list.is_at_end()) { if (with_centering) { @@ -43,7 +43,7 @@ exports.down = function (with_centering) { }; exports.to_home = function () { - message_viewport.last_movement_direction = -1; + message_viewport.set_last_movement_direction(-1); var first_id = current_msg_list.first().id; current_msg_list.select_id(first_id, {then_scroll: true, from_scroll: true}); @@ -51,7 +51,7 @@ exports.to_home = function () { exports.to_end = function () { var next_id = current_msg_list.last().id; - message_viewport.last_movement_direction = 1; + message_viewport.set_last_movement_direction(1); current_msg_list.select_id(next_id, {then_scroll: true, from_scroll: true}); unread_ops.mark_current_list_as_read(); diff --git a/static/js/ui_init.js b/static/js/ui_init.js index 4aab6244a4..009d17f425 100644 --- a/static/js/ui_init.js +++ b/static/js/ui_init.js @@ -70,7 +70,7 @@ exports.initialize_kitchen_sink_stuff = function () { } } - message_viewport.last_movement_direction = delta; + message_viewport.set_last_movement_direction(delta); }, 50); message_viewport.message_pane.on('wheel', function (e) {