Enable horizontal scrolling without shift modifier

Fixes #2359.
This commit is contained in:
Matt Woelfel 2024-05-13 21:16:19 -05:00 committed by Héctor Ramón Jiménez
parent c8686c5173
commit 0a0ea30059
No known key found for this signature in database
GPG key ID: 7CC46565708259A7

View file

@ -706,15 +706,29 @@ where
let delta = match delta {
mouse::ScrollDelta::Lines { x, y } => {
// TODO: Configurable speed/friction (?)
let movement = if !cfg!(target_os = "macos") // macOS automatically inverts the axes when Shift is pressed
&& state.keyboard_modifiers.shift()
{
Vector::new(y, x)
} else {
Vector::new(x, y)
let is_shift_pressed = state.keyboard_modifiers.shift();
// macOS automatically inverts the axes when Shift is pressed
let (x, y) =
if cfg!(target_os = "macos") && is_shift_pressed {
(y, x)
} else {
(x, y)
};
let is_vertical = match self.direction {
Direction::Vertical(_) => true,
Direction::Horizontal(_) => false,
Direction::Both { .. } => !is_shift_pressed,
};
let movement = if is_vertical {
Vector::new(x, y)
} else {
Vector::new(y, x)
};
// TODO: Configurable speed/friction (?)
movement * 60.0
}
mouse::ScrollDelta::Pixels { x, y } => Vector::new(x, y),