Image Pinch and Zoom - gestures


#1

Has anyone had success in making an image work with pinch and zoom. I need the ability for both platforms. I can respond to gestures, and by default a large image can be moved around by sliding. However nothing I have done makes the pinch or zoom feature work.


#2

I have found a solution to this that works well for iOS. If anyone is looking to implement pinch and zoom for images, contact me.


#3

Feel free to share it with the rest of us who might need this at some point. Better yet, post a new thread in the Tips & Tricks category.


#4

Yes please. This is something I’ve also been trying to figure out without a good solution yet.


#5

This should work

import { ScrollView } from "ui/scroll-view";

export class CustomScrollView extends ScrollView {
    constructor() {
        super();
        const view: UIScrollView = this.ios;
        view.delegate = UIScrollViewDelegateImpl.new();
        view.minimumZoomScale = 1.0;
        view.maximumZoomScale = 3.0;
    }
}
export class UIScrollViewDelegateImpl extends NSObject implements UIScrollViewDelegate {
    public static ObjCProtocols = [UIScrollViewDelegate];
    viewForZoomingInScrollView(scrollView: UIScrollView) {
        return scrollView.subviews[0];
    }
}
<CustomScrollView>
    <Image src="someImage"/>
</CustomScrollView>

#6

Thanks Pete. I need to wrap up the solution and create a post.


#7

Did you try the solution below? What I am doing is somewhat different. Happy to share it with you directly now, I will formalize something for posting in the next couple of days.