mirror of
https://github.com/servo/servo.git
synced 2025-08-07 14:35:33 +01:00
Auto merge of #10387 - tschneidereit:snap-scroll-axis, r=paulrouget
Snap scrolling to major axis of movement This is what Safari does, and it leads to much better behavior, in particular wrt overscrolling. It does cause a staircase effect when scrolling diagonally, which again Safari has, too. I don't think that bad, because it should occur very rarely in practice. Fixes #10341 <!-- Reviewable:start --> --- This change is [<img src="https://reviewable.io/review_button.svg" height="35" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/10387) <!-- Reviewable:end -->
This commit is contained in:
commit
84b30b0641
1 changed files with 8 additions and 1 deletions
|
@ -266,7 +266,14 @@ impl Window {
|
|||
}
|
||||
|
||||
/// Helper function to send a scroll event.
|
||||
fn scroll_window(&self, dx: f32, dy: f32, phase: TouchEventType) {
|
||||
fn scroll_window(&self, mut dx: f32, mut dy: f32, phase: TouchEventType) {
|
||||
// Scroll events snap to the major axis of movement, with vertical
|
||||
// preferred over horizontal.
|
||||
if dy.abs() >= dx.abs() {
|
||||
dx = 0.0;
|
||||
} else {
|
||||
dy = 0.0;
|
||||
}
|
||||
let mouse_pos = self.mouse_pos.get();
|
||||
let event = WindowEvent::Scroll(Point2D::typed(dx as f32, dy as f32),
|
||||
Point2D::typed(mouse_pos.x as i32, mouse_pos.y as i32),
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue