mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 07:23:22 +00:00
pointer: Move scroll suppression to message_scroll.js.
This is clearly a better home for it, since message_scroll.js is the only place that reads it, and also lets us provide a clearer name for the functionality.
This commit is contained in:
@@ -1,5 +1,13 @@
|
||||
let actively_scrolling = false;
|
||||
|
||||
// Tracks whether the next scroll that will complete is initiated by
|
||||
// code, not the user, and thus should avoid moving the selected
|
||||
// message.
|
||||
let update_selection_on_next_scroll = true;
|
||||
exports.suppress_selection_update_on_next_scroll = function () {
|
||||
update_selection_on_next_scroll = false;
|
||||
};
|
||||
|
||||
let loading_older_messages_indicator_showing = false;
|
||||
let loading_newer_messages_indicator_showing = false;
|
||||
exports.show_loading_older = function () {
|
||||
@@ -111,10 +119,10 @@ exports.scroll_finished = function () {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!pointer.suppress_scroll_pointer_update) {
|
||||
if (update_selection_on_next_scroll) {
|
||||
message_viewport.keep_pointer_in_view();
|
||||
} else {
|
||||
pointer.set_suppress_scroll_pointer_update(false);
|
||||
update_selection_on_next_scroll = true;
|
||||
}
|
||||
|
||||
floating_recipient_bar.update();
|
||||
|
||||
@@ -123,7 +123,7 @@ exports.set_message_position = function (message_top, message_height, viewport_i
|
||||
message_top
|
||||
- message_offset;
|
||||
|
||||
pointer.set_suppress_scroll_pointer_update(true); // Gets set to false in the scroll handler.
|
||||
message_scroll.suppress_selection_update_on_next_scroll();
|
||||
exports.scrollTop(new_scroll_top);
|
||||
};
|
||||
|
||||
@@ -280,7 +280,7 @@ exports.is_narrow = function () {
|
||||
};
|
||||
|
||||
exports.system_initiated_animate_scroll = function (scroll_amount) {
|
||||
pointer.set_suppress_scroll_pointer_update(true); // Gets set to false in the scroll handler.
|
||||
message_scroll.suppress_selection_update_on_next_scroll();
|
||||
const viewport_offset = exports.scrollTop();
|
||||
in_stoppable_autoscroll = true;
|
||||
exports.message_pane.animate({
|
||||
@@ -292,7 +292,7 @@ exports.system_initiated_animate_scroll = function (scroll_amount) {
|
||||
};
|
||||
|
||||
exports.user_initiated_animate_scroll = function (scroll_amount) {
|
||||
pointer.set_suppress_scroll_pointer_update(true); // Gets set to false in the scroll handler.
|
||||
message_scroll.suppress_selection_update_on_next_scroll();
|
||||
in_stoppable_autoscroll = false; // defensive
|
||||
|
||||
const viewport_offset = exports.scrollTop();
|
||||
|
||||
@@ -6,13 +6,6 @@ exports.set_recenter_pointer_on_display = function (value) {
|
||||
exports.recenter_pointer_on_display = 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.initialize = function initialize() {
|
||||
$(document).on('message_selected.zulip', function (event) {
|
||||
if (event.id === -1) {
|
||||
|
||||
@@ -35,7 +35,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.set_suppress_scroll_pointer_update(true);
|
||||
message_scroll.suppress_selection_update_on_next_scroll();
|
||||
|
||||
if (!home_msg_list.empty()) {
|
||||
message_util.do_unread_count_updates(home_msg_list.all_messages());
|
||||
|
||||
Reference in New Issue
Block a user