Skip to content

Commit

Permalink
fixes iced-rs#2359
Browse files Browse the repository at this point in the history
The current implementation strictly scrolls vertically without the shift
modifier and horizontally with the shift modifier. This patch checks the
modifier only when the direction is Both.
  • Loading branch information
woelfman committed May 14, 2024
1 parent e69e2c0 commit 41ef776
Showing 1 changed file with 12 additions and 6 deletions.
18 changes: 12 additions & 6 deletions widget/src/scrollable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -564,12 +564,18 @@ 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 movement = match self.direction {
Direction::Vertical(_) => Vector::new(x, y),
Direction::Horizontal(_) => Vector::new(y, x),
Direction::Both { vertical: _, horizontal: _ } => {
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)
}
}
};

movement * 60.0
Expand Down

0 comments on commit 41ef776

Please sign in to comment.