Fix for macos fast scroll when pixel delta is received (#898)

typo
This commit is contained in:
Dragos Daian
2026-02-11 18:54:27 +03:00
committed by GitHub
parent 84de4fed7a
commit 15afcf3977
2 changed files with 17 additions and 2 deletions
+2 -1
View File
@@ -110,4 +110,5 @@ fabric.properties
# Resource Metadata
*.meta
*.registry
*.registry
.DS_Store
+15 -1
View File
@@ -529,7 +529,21 @@ pub fn translate_event(event: &WindowEvent) -> Option<OsEvent> {
WindowEvent::MouseWheel { delta, .. } => match delta {
MouseScrollDelta::LineDelta(x, y) => Some(OsEvent::MouseWheel(*x, *y)),
MouseScrollDelta::PixelDelta(pos) => {
Some(OsEvent::MouseWheel(pos.x as f32, pos.y as f32))
#[cfg(target_os = "macos")]
{
// macOS trackpads emits pixel deltas; scale to line-like units to avoid excessive scroll speed.
const PIXELS_PER_LINE: f32 = 100.0;
Some(OsEvent::MouseWheel(
pos.x as f32 / PIXELS_PER_LINE,
pos.y as f32 / PIXELS_PER_LINE,
))
}
#[cfg(not(target_os = "macos"))]
{
Some(OsEvent::MouseWheel(pos.x as f32, pos.y as f32))
}
}
},
WindowEvent::MouseInput { state, button, .. } => Some(OsEvent::MouseInput {