Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Preventing default iOS webpage drag with javascript and hammerJS

I am creating a simple web app that uses the new version of hammerJS for pinch zooming. I am having an issue with the default iOS page drag when a pinch starts. This seams to override the pinch event that I am attempting to capture. Any help stoping this while using hammerJS would be greatly appreciated.

PS: I have attempted to use event.preventDefault() to no avail.

like image 454
Mike Bonds Avatar asked Nov 13 '22 08:11

Mike Bonds


1 Answers

You need to call preventDefault slightly differently to how you may be used to. Like so:

 $('#your_element').on('pinch', function(event) {
      event.gesture.preventDefault();
 });

See this hammer.js example for another example.

like image 165
Josh Davenport-Smith Avatar answered Nov 14 '22 23:11

Josh Davenport-Smith