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.
This commit is contained in:
Killy 2020-04-30 17:39:03 +03:00
commit 464e5e872f

View file

@ -1581,10 +1581,19 @@ namespace Greenshot {
} }
// Store old scroll position // 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 rc = surface.GetVisibleRectangle();
var size = surface.Size; var size = surface.Size;
var horizontalCenter = 1.0 * (rc.Left + rc.Width / 2) / size.Width; if (size.Width > rc.Width)
var verticalCenter = 1.0 * (rc.Top + rc.Height / 2) / size.Height; {
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 // Set the new zoom value
_zoomValue = value; _zoomValue = value;