Merge pull request #2392 from woelfman/fix-horizontal-scroll
Enable horizontal scrolling without shift modifier
This commit is contained in:
commit
630f3525dd
1 changed files with 21 additions and 7 deletions
|
|
@ -706,15 +706,29 @@ where
|
||||||
|
|
||||||
let delta = match delta {
|
let delta = match delta {
|
||||||
mouse::ScrollDelta::Lines { x, y } => {
|
mouse::ScrollDelta::Lines { x, y } => {
|
||||||
// TODO: Configurable speed/friction (?)
|
let is_shift_pressed = state.keyboard_modifiers.shift();
|
||||||
let movement = if !cfg!(target_os = "macos") // macOS automatically inverts the axes when Shift is pressed
|
|
||||||
&& state.keyboard_modifiers.shift()
|
// macOS automatically inverts the axes when Shift is pressed
|
||||||
{
|
let (x, y) =
|
||||||
Vector::new(y, x)
|
if cfg!(target_os = "macos") && is_shift_pressed {
|
||||||
} else {
|
(y, x)
|
||||||
Vector::new(x, y)
|
} 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
|
movement * 60.0
|
||||||
}
|
}
|
||||||
mouse::ScrollDelta::Pixels { x, y } => Vector::new(x, y),
|
mouse::ScrollDelta::Pixels { x, y } => Vector::new(x, y),
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue