Take into account multiple scroll deltas within a single frame (#3982)

Release Notes:

- Fixed an issue where all but the last scroll event would be dropped if
there were multiple within a single frame.
This commit is contained in:
Julia 2024-01-09 14:51:26 -05:00 committed by GitHub
commit 5b1894a9b1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 74 additions and 51 deletions

View file

@ -178,6 +178,20 @@ impl ScrollDelta {
ScrollDelta::Lines(delta) => point(line_height * delta.x, line_height * delta.y),
}
}
pub fn coalesce(self, other: ScrollDelta) -> ScrollDelta {
match (self, other) {
(ScrollDelta::Pixels(px_a), ScrollDelta::Pixels(px_b)) => {
ScrollDelta::Pixels(px_a + px_b)
}
(ScrollDelta::Lines(lines_a), ScrollDelta::Lines(lines_b)) => {
ScrollDelta::Lines(lines_a + lines_b)
}
_ => other,
}
}
}
#[derive(Clone, Debug, Default)]