diff --git a/news.d/47.beta/fixed-zoom-into-image-center b/news.d/47.beta/fixed-zoom-into-image-center new file mode 100644 index 0000000..f08773d --- /dev/null +++ b/news.d/47.beta/fixed-zoom-into-image-center @@ -0,0 +1 @@ +Zoom into viewport center via buttons. Before, the image center was used, which would cause a jump if the viewport had been changed. diff --git a/src/widgets/image/zoom.rs b/src/widgets/image/zoom.rs index d78900c..addcd56 100644 --- a/src/widgets/image/zoom.rs +++ b/src/widgets/image/zoom.rs @@ -183,9 +183,8 @@ impl imp::LpImage { // Get image coordinate from the passed cursor position self.widget_to_img_coord(cur_pos) } else { - // Use center of image - let (width, height) = obj.image_size(); - (width as f64 / 2., height as f64 / 2.) + // 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 {