Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable horizontal scrolling without shift modifier #2392

Merged
merged 1 commit into from
Sep 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 20 additions & 6 deletions widget/src/scrollable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
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),
Expand Down
Loading