Limited Zooming - Content shifts sideways
#1
Hi there

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

Regards

Paul
#2
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:
https://github.com/ab4d/Ab2d.Controls.Zo...ng.xaml.cs
Andrej Benedik
#3
Hi

Thanks for the update, this worked perfectly.
  


Forum Jump:


Users browsing this thread:
1 Guest(s)