Simplest way to detect a pinch

前端 未结 7 2038
清酒与你
清酒与你 2020-11-28 19:29

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 metho

7条回答
  •  情深已故
    2020-11-28 20:14

    Unfortunately, detecting pinch gestures across browsers is a not as simple as one would hope, but HammerJS makes it a lot easier!

    Check out the Pinch Zoom and Pan with HammerJS demo. This example has been tested on Android, iOS and Windows Phone.

    You can find the source code at Pinch Zoom and Pan with HammerJS.

    For your convenience, here is the source code:

    
    
    
      
      
      Pinch Zoom
    
    
    
    
      
    Ignore this area. Space is needed to test on the iPhone simulator as pinch simulation on the iPhone simulator requires the target to be near the middle of the screen and we only respect touch events in the image area. This space is not needed in production.

提交回复
热议问题