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) {