Prevent iOS webpage drag and drop using javascript and hammerJS

I am creating a simple web application that uses the new version of hammerJS to scale. I am having trouble dragging the default iOS page when the pinch starts. These seams overlap the pinch event that I am trying to capture. Any help to stop this while using hammerJS would be greatly appreciated.

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

+5
source share
3 answers

You need to name a preventDefaultlittle differently than you can use. For instance:

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

See this example hammer.js for another example.

+1

:

<meta name="viewport" content="width=device-width,user-scalable=no">

, . , , hammerJs.

https://developer.mozilla.org/en-US/docs/Mobile/Viewport_meta_tag#Viewport_basics

0

What did you call preventDefault for? I usually combine @Bertrand's answer with something like this

$(body).on('touchmove', function(e){
    e.preventDefault();
});
0
source

All Articles