diff --git a/CHANGELOG.md b/CHANGELOG.md index 2b3b767f..2bb45197 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,7 @@ - On iOS and Android, `set_inner_size` is now a no-op instead of a runtime crash. - On Android, fix `ControlFlow::Poll` not polling the Android event queue. - On macOS, add `NSWindow.hasShadow` support. +- On Web, fix vertical mouse wheel scrolling being inverted. - **Breaking:** On Web, `set_cursor_position` and `set_cursor_grab` will now always return an error. - **Breaking:** `PixelDelta` scroll events now return a `PhysicalPosition`. - On NetBSD, fixed crash due to incorrect detection of the main thread. diff --git a/src/platform_impl/web/stdweb/event.rs b/src/platform_impl/web/stdweb/event.rs index 8464c616..d57f9bb5 100644 --- a/src/platform_impl/web/stdweb/event.rs +++ b/src/platform_impl/web/stdweb/event.rs @@ -32,7 +32,7 @@ pub fn mouse_position(event: &impl IMouseEvent) -> LogicalPosition { pub fn mouse_scroll_delta(event: &MouseWheelEvent) -> Option { let x = event.delta_x(); - let y = event.delta_y(); + let y = -event.delta_y(); match event.delta_mode() { MouseWheelDeltaMode::Line => Some(MouseScrollDelta::LineDelta(x as f32, y as f32)), diff --git a/src/platform_impl/web/web_sys/event.rs b/src/platform_impl/web/web_sys/event.rs index a0641841..316b4f27 100644 --- a/src/platform_impl/web/web_sys/event.rs +++ b/src/platform_impl/web/web_sys/event.rs @@ -31,7 +31,7 @@ pub fn mouse_position(event: &MouseEvent) -> LogicalPosition { pub fn mouse_scroll_delta(event: &WheelEvent) -> Option { let x = event.delta_x(); - let y = event.delta_y(); + let y = -event.delta_y(); match event.delta_mode() { WheelEvent::DOM_DELTA_LINE => Some(MouseScrollDelta::LineDelta(x as f32, y as f32)),