From 004a1f3848fe279a6222c960f84ab271b792a7a0 Mon Sep 17 00:00:00 2001 From: Malcolm Ramsay Date: Thu, 3 Aug 2023 08:42:46 +0930 Subject: [PATCH 1/3] fix: Check cursor in bounds when scrolling image::Viewer Ensure that the cursor is within the bounds of the image::Viewer when performing the scrolling. Fixes #1997 --- widget/src/image/viewer.rs | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/widget/src/image/viewer.rs b/widget/src/image/viewer.rs index 0038f85870..c04ddfa677 100644 --- a/widget/src/image/viewer.rs +++ b/widget/src/image/viewer.rs @@ -154,7 +154,8 @@ where match event { Event::Mouse(mouse::Event::WheelScrolled { delta }) => { - let Some(cursor_position) = cursor.position() else { + // Ensure the cursor is within the bounds of the widget + let Some(cursor_position) = cursor.position_over(bounds) else { return event::Status::Ignored; }; From 085842e7651d1ff7794417fe787727347315c3e5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Thu, 3 Aug 2023 20:18:31 +0200 Subject: [PATCH 2/3] Remove unnecessary comment in `image::viewer` --- widget/src/image/viewer.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/widget/src/image/viewer.rs b/widget/src/image/viewer.rs index c04ddfa677..6e09566793 100644 --- a/widget/src/image/viewer.rs +++ b/widget/src/image/viewer.rs @@ -154,7 +154,6 @@ where match event { Event::Mouse(mouse::Event::WheelScrolled { delta }) => { - // Ensure the cursor is within the bounds of the widget let Some(cursor_position) = cursor.position_over(bounds) else { return event::Status::Ignored; }; From 30d5361f6369bb0f619191c38de51561bd4b26cc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?H=C3=A9ctor=20Ram=C3=B3n=20Jim=C3=A9nez?= Date: Thu, 3 Aug 2023 20:19:45 +0200 Subject: [PATCH 3/3] Update `CHANGELOG` --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index e363714963..8e838f8d5b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -81,6 +81,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - `BorderRadius` not exposed in root crate. [#1972](https://github.com/iced-rs/iced/pull/1972) - Outdated `ROADMAP`. [#1958](https://github.com/iced-rs/iced/pull/1958) - `iced_wgpu` freezing on empty layers. [#1996](https://github.com/iced-rs/iced/pull/1996) +- `image::Viewer` reacting to any scroll event. [#1998](https://github.com/iced-rs/iced/pull/1998) Many thanks to... @@ -99,6 +100,7 @@ Many thanks to... - @JonathanLindsey - @kr105 - @marienz +- @malramsay64 - @nicksenger - @nicoburns - @Redhawk18