From f255af9f6a6e2ce29c38673685e745f475b9040f Mon Sep 17 00:00:00 2001 From: Sophie Herold Date: Wed, 10 Dec 2025 22:16:20 +0100 Subject: [PATCH] image/zoom: Keep best-fit zoom in gesture Don't change the zoom in configure best fit if currently in gesture. --- news.d/49.2/fixed-zoom-gesture-jump | 1 + src/widgets/image/zoom.rs | 15 +++++++++++---- 2 files changed, 12 insertions(+), 4 deletions(-) create mode 100644 news.d/49.2/fixed-zoom-gesture-jump diff --git a/news.d/49.2/fixed-zoom-gesture-jump b/news.d/49.2/fixed-zoom-gesture-jump new file mode 100644 index 0000000..ff5c8a3 --- /dev/null +++ b/news.d/49.2/fixed-zoom-gesture-jump @@ -0,0 +1 @@ +Don't jump to best-fit zoom level during pinch zoom gesture when scroolbars get displayed. This has only been an issue with the disability option "always show scrollbars." diff --git a/src/widgets/image/zoom.rs b/src/widgets/image/zoom.rs index 2a6f19f..058c8b5 100644 --- a/src/widgets/image/zoom.rs +++ b/src/widgets/image/zoom.rs @@ -70,12 +70,19 @@ impl imp::LpImage { /// Sets respective output values if best-fit is active pub(super) fn configure_best_fit(&self) { + log::trace!("Configure best fit"); // calculate new zoom value for best fit if self.obj().is_best_fit() { - let best_fit_level = self.zoom_level_best_fit(); - self.zoom.set(best_fit_level); - self.set_zoom_target(best_fit_level); - self.zoom_animation().pause(); + // LpImage can get measured during pinch zoom gesture, when scrollbars appear + // that are not overlayed (accessibility option.) This causes the best-fit to + // change. Don't change the zoom level in this case since we are in the gesture + // that will change the zoom level anyway. + if self.locked_gestured.get().is_none() { + let best_fit_level = self.zoom_level_best_fit(); + self.zoom.set(best_fit_level); + self.set_zoom_target(best_fit_level); + self.zoom_animation().pause(); + } self.configure_adjustments(); } }