From 1f28884847f6f9b5a5d7b756473d85e32dbc5bc4 Mon Sep 17 00:00:00 2001 From: Sophie Herold Date: Wed, 11 Sep 2024 12:30:38 +0200 Subject: [PATCH] image/zoom: Fix forcing center aim not working --- news.d/47.0/fixed-zoom-center | 1 + src/widgets/image/zoom.rs | 10 ++++++---- 2 files changed, 7 insertions(+), 4 deletions(-) create mode 100644 news.d/47.0/fixed-zoom-center diff --git a/news.d/47.0/fixed-zoom-center b/news.d/47.0/fixed-zoom-center new file mode 100644 index 0000000..f7c4327 --- /dev/null +++ b/news.d/47.0/fixed-zoom-center @@ -0,0 +1 @@ +Forcing the zoom to the center of the image is now working again. This is especially noticable when using the touchpads pinch gesture. diff --git a/src/widgets/image/zoom.rs b/src/widgets/image/zoom.rs index 8247e9d..492c49a 100644 --- a/src/widgets/image/zoom.rs +++ b/src/widgets/image/zoom.rs @@ -179,16 +179,18 @@ impl imp::LpImage { let img_pos = if let Some(img_pos) = self.zoom_cursor_target.get() { // Point is stored for animation img_pos - } else if let Some(cur_pos) = cur { - // Get image coordinate from the passed cursor position - self.widget_to_img_coord(cur_pos) } else { // Use center of viewport self.widget_to_img_coord((self.widget_width() / 2., self.widget_height() / 2.)) }; let cur_pos = if let Some(cur) = cur { - cur + if self.zoom_cursor_target.get().is_some() { + cur + } else { + // Use center of widget for cursor since `img_pos` is locked in on center + (self.widget_width() / 2., self.widget_height() / 2.) + } } else { // Use center of widget since no cursor position available (self.widget_width() / 2., self.widget_height() / 2.)