mirror of
https://github.com/zulip/zulip.git
synced 2026-07-15 21:03:26 +08:00
Fix pointer jumps on unnarrowing after certain scroll events.
This appears to have been caused by our code for preventing the viewport from being recentered if you move the pointer away from the edge of the viewport from a position near the edge, which was being run even when it was not triggered by a scroll event. (imported from commit 0a4b3dcca75a6e5dbf1beb77a5249bd6a9c61341)
This commit is contained in:
parent
11ad134f7b
commit
3a93c8cc90
@ -101,9 +101,10 @@ function process_hotkey(e) {
|
||||
|
||||
if (directional_hotkeys_id.hasOwnProperty(code)) {
|
||||
dirkey = directional_hotkeys_id[code];
|
||||
last_viewport_movement_direction = dirkey.direction;
|
||||
var next_id = dirkey.getid();
|
||||
current_msg_list.select_id(next_id, {then_scroll: true});
|
||||
last_viewport_movement_direction = dirkey.direction;
|
||||
current_msg_list.select_id(next_id, {then_scroll: true,
|
||||
from_scroll: true});
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -112,7 +113,9 @@ function process_hotkey(e) {
|
||||
last_viewport_movement_direction = dirkey.direction;
|
||||
next_row = dirkey.getrow(current_msg_list.selected_row());
|
||||
if (next_row.length !== 0) {
|
||||
current_msg_list.select_id(rows.id(next_row), {then_scroll: true});
|
||||
current_msg_list.select_id(rows.id(next_row),
|
||||
{then_scroll: true,
|
||||
from_scroll: true});
|
||||
}
|
||||
if ((next_row.length === 0) && (code === 40 || code === 106)) {
|
||||
// At the last message, scroll to the bottom so we have
|
||||
|
||||
@ -969,7 +969,7 @@ $(function () {
|
||||
row.addClass('selected_message');
|
||||
|
||||
if (event.then_scroll) {
|
||||
recenter_view(row);
|
||||
recenter_view(row, event.from_scroll);
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
@ -95,7 +95,7 @@ function below_view_threshold(message) {
|
||||
return message.offset().top > viewport.scrollTop() + viewport.height() * 2 / 3;
|
||||
}
|
||||
|
||||
function recenter_view(message) {
|
||||
function recenter_view(message, from_scroll) {
|
||||
// Barnowl-style recentering: if the pointer is too high, center
|
||||
// in the middle of the screen. If the pointer is too low, center
|
||||
// on the 1/5-mark.
|
||||
@ -105,10 +105,11 @@ function recenter_view(message) {
|
||||
var selected_row = current_msg_list.selected_row();
|
||||
var selected_row_top = selected_row.offset().top;
|
||||
|
||||
if ((above_view_threshold(message, true) &&
|
||||
(last_viewport_movement_direction >= 0)) ||
|
||||
(below_view_threshold(message) &&
|
||||
(last_viewport_movement_direction <= 0))) {
|
||||
if (from_scroll !== undefined && from_scroll &&
|
||||
((above_view_threshold(message, true) &&
|
||||
(last_viewport_movement_direction >= 0)) ||
|
||||
(below_view_threshold(message) &&
|
||||
(last_viewport_movement_direction <= 0)))) {
|
||||
// If the message you're trying to center on is already in view AND
|
||||
// you're already trying to move in the direction of that message,
|
||||
// don't try to recenter. This avoids disorienting jumps when the
|
||||
@ -985,7 +986,7 @@ function keep_pointer_in_view() {
|
||||
if (! adjust(above_view_threshold, at_top_of_viewport, rows.next_visible))
|
||||
adjust(below_view_threshold, at_bottom_of_viewport, rows.prev_visible);
|
||||
|
||||
current_msg_list.select_id(rows.id(next_row));
|
||||
current_msg_list.select_id(rows.id(next_row), {from_scroll: true});
|
||||
}
|
||||
|
||||
// The idea here is when you've scrolled to the very
|
||||
|
||||
Loading…
Reference in New Issue
Block a user