Limited Zooming - Content shifts sideways - Printable Version
+- AB4D Forum (https://forum.ab4d.com)
+-- Forum: Products Forums (https://forum.ab4d.com/forumdisplay.php?fid=4)
+--- Forum: ZoomPanel (https://forum.ab4d.com/forumdisplay.php?fid=8)
+--- Thread: Limited Zooming - Content shifts sideways (/showthread.php?tid=4332)
Limited Zooming - Content shifts sideways - PWVidendum - 09-12-2022
I need to limit the zooming when using the mouse wheel so I looked at the Limited Zooming Sample. It was easy enough to add the code to my project and it works but I noticed an issue when you zoom all the way in, then zoom out a little and back in. The second time you reach the limit of the zoom the code to center the image doesn't calculate the correct values and the image jumps diagonally. It appears the values returned in OldViewboxValue on the second time you reach the zoom limit differ substantially from those set in NewViewboxValue when the center was re-calculated the first time and this causes the second calculation to shift the center of the viewbox.
It appears to only be a problem when using the mouse wheel.
I haven't been able to work out how to cater for this shift in values. Any help would be greatly appreciated
RE: Limited Zooming - Content shifts sideways - abenedik - 09-13-2022
The problem was that when the zooming was limited, the new center position was not correctly calculated (center position was moved as the zoom was not limited). The fix was to adjust moving the center position for the amount that was a fraction of the whole move - the same fraction as the actually performed zooming.
The new source code with the fix is here:
RE: Limited Zooming - Content shifts sideways - PWVidendum - 09-14-2022
Thanks for the update, this worked perfectly.