This is a WEB APP not a native app. Please no Objective-C NS commands.
So I need to detect ‘pinch’ events on iOS. Problem is every plugin or method I see for doing gestures or multi-touch events, is (usually) with jQuery and is a whole additional pluggin for every gesture under the sun. My application is huge, and I am very sensitive to deadwood in my code. All I need is to detect a pinch, and using something like jGesture is just way to bloated for my simple needs.
Additionally, I have a limited understanding of how to detect a pinch manually. I can get the position of both fingers, can’t seem to get the mix right to detect this. Does anyone have a simple snippet that JUST detects pinch?
You want to use the
gesturestart,gesturechange, andgestureendevents. These get triggered any time 2 or more fingers touch the screen.Depending on what you need to do with the pinch gesture, your approach will need to be adjusted. The
scalemultiplier can be examined to determine how dramatic the user’s pinch gesture was. See Apple’s TouchEvent documentation for details about how thescaleproperty will behave.You could also intercept the
gesturechangeevent to detect a pinch as it happens if you need it to make your app feel more responsive.