How to detect when image is clipped to turn panning on - 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: How to detect when image is clipped to turn panning on (/showthread.php?tid=4146)
How to detect when image is clipped to turn panning on - jez - 08-14-2019
Similar to previous question ...
I am looking at an 1920x1080 image in a ZoomPanel. I am using mouse and touch.
When the image is completely visible, I want to pin it to center position and prevent mouse/touch panning.
When the image is clipped because of zoom in, I want to allow panning to view otherwise hidden pixels.
I can prevent the panning but I cant seem to figure out when the image is clipping to turn panning on and off at the right moment.
RE: How to detect when image is clipped to turn panning on - abenedik - 08-14-2019
You can check various properties on ZoomPanel to see if you are zooming in or out.
One is ZoomFactor - when it is bigger the 1, then you are zooming in.
The other is Viewbox - when its width and height are smaller than 1, then you are zooming in.
To see examples of the values and some other possible properties check the "ZoomPanelDump" sample under ZoomPanel section.
RE: How to detect when image is clipped to turn panning on - jez - 08-15-2019
Thanks for the reply.
When ZoomFactor is 1 the image is not clipped so I can turn off panning completely.
When ZoomFactor is 1.3, the image is clipped at top/bottom but not left/right so I want to allow vertical panning only.
Thats what I am trying to do.
RE: How to detect when image is clipped to turn panning on - jez - 08-22-2019
I have been experimenting with your touch sample with the tiger.
Can you please explain the best way to stop the tiger being dragged around when zoomed out. I want it to be in a fixed position until the zoom level requires panning.
RE: How to detect when image is clipped to turn panning on - abenedik - 08-26-2019
When zoomed out it is not very intuitive how to preserve the content of the ZoomPanel centered. To do this you need to first subtract 1 from viewbox.width and height, then divide this by 2 and negate the values - this gives you the correct x and y values for the viewbox.
The following code does the trick (the method handles the PreviewViewboxChanged event):