Merge pull request #816 from ellieplayswow/bugfix/drag-scroll-virtual-cursor-desync

Bugfix to how virtual cursor is calculated before DragEnd when drag-scrolling
This commit is contained in:
Jeremy Soller 2025-02-21 06:49:03 -07:00 committed by GitHub
commit cd43d722d6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 65 additions and 33 deletions

View file

@ -2241,24 +2241,7 @@ impl Tab {
0.0
};
let mut new_offset = Point {
x: 0.0,
y: scroll_y
};
if let Some(virtual_cursor_offset) = self.virtual_cursor_offset {
new_offset = Point {
x: new_offset.x + virtual_cursor_offset.x,
y: new_offset.y + virtual_cursor_offset.y,
};
}
if let Some(last_scroll_position) = self.last_scroll_position {
new_offset.x = pos.x - last_scroll_position.x;
}
self.virtual_cursor_offset = Some(new_offset);
self.last_scroll_offset = Some(new_offset);
commands.push(Command::AutoScroll(Some(scroll_y)));
}
@ -2962,6 +2945,28 @@ impl Tab {
self.scroll_opt = Some(viewport.absolute_offset());
}
Message::ScrollTab(scroll_speed) => {
let mut new_offset = Point {
x: 0.0,
y: scroll_speed
};
if let Some(virtual_cursor_offset) = self.virtual_cursor_offset {
new_offset = Point {
x: new_offset.x + virtual_cursor_offset.x,
y: new_offset.y + virtual_cursor_offset.y,
};
}
if let Some(last_scroll_position) = self.last_scroll_position {
if let Some(global_cursor_position) = self.global_cursor_position {
new_offset.x = global_cursor_position.x - last_scroll_position.x;
}
}
self.virtual_cursor_offset = Some(new_offset);
self.last_scroll_offset = Some(new_offset);
commands.push(Command::Iced(
scrollable::scroll_by(self.scrollable_id.clone(), AbsoluteOffset {
x: 0.0,