From 464e5e872f723b2cd0df343c5b82c309088a41c6 Mon Sep 17 00:00:00 2001 From: Killy Date: Thu, 30 Apr 2020 17:39:03 +0300 Subject: [PATCH] Fix weird scroll position when going from no scroll zoom value Also prefer top left corner in that situation - it is less disorienting when working with screenshots. --- Greenshot/Forms/ImageEditorForm.cs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/Greenshot/Forms/ImageEditorForm.cs b/Greenshot/Forms/ImageEditorForm.cs index 334a72dc3..ca0cb1a7b 100644 --- a/Greenshot/Forms/ImageEditorForm.cs +++ b/Greenshot/Forms/ImageEditorForm.cs @@ -1581,10 +1581,19 @@ namespace Greenshot { } // Store old scroll position + // When no scroll is currently needed - prefer top left corner. + var horizontalCenter = 0.0; + var verticalCenter = 0.0; var rc = surface.GetVisibleRectangle(); var size = surface.Size; - var horizontalCenter = 1.0 * (rc.Left + rc.Width / 2) / size.Width; - var verticalCenter = 1.0 * (rc.Top + rc.Height / 2) / size.Height; + if (size.Width > rc.Width) + { + horizontalCenter = 1.0 * (rc.Left + rc.Width / 2) / size.Width; + } + if (size.Height > rc.Height) + { + verticalCenter = 1.0 * (rc.Top + rc.Height / 2) / size.Height; + } // Set the new zoom value _zoomValue = value;