I recently developed a MAUI app and needed a control that would allow the user to view an Image, like an Android/iOS photo album, I triedBertuzzi.MAUI.PinchZoomImage,but it had some UX issues, then I tried reading the documentation.NET MAUI Docs/Recognize a pangesture,.NET MAUI Docs/Recognize a pinch gesture,After a few days of lots of attempts, I finally implemented the MauiPanPinchContainer!
Honestly, the code is all mathematical calculations, and I don't fully understand it, so if I could, I'd like to see in the codeContnet.Anchor
to stay at the default value of 0.5 (I'm not sure if 0.5 is better), but I'm limited in my ability/time to do that for now.
There are no plans to release a NuGet version for the time being, as PanPinchContainer is still very simple in its functionality, with hard-coded parameters, lack of flexibility, and no customizable dependency properties
<PanPinchContainer>
<ImageSource="hello_maui.jpg"/>
<PanPinchContainer>
- 1x ~ 10x Scaling: Supports scaling from 1x to 10x.
- 0.5x Temporarily Scaling: Supports pinch and temporarily scale down the image below 1x. Upon release, the image restores to 1x.
- Boundary Constraints: Limits scaling and panning within image boundaries.
- Double Tap to Zoom: Double tap to zoom in (2x) or zoom out (1x).
- Scaling Based on Pinch Position: Scale based on the position of the pinch gesture.
- Panning and Zooming Animation: Smooth panning and zooming animations.
- Rotation
- Inertial panning
- Slightly more than 10x temporarily scaling