javascripthammer.jspinchzoom

How to keep default browser behavior (zoom) on pinch with Hammerjs?


I use Hammerjs for swiping and tapping. However as soon as I start using it on any element

var hammer = new Hammer(document.getElementById("square"));

the default browser's behavior for "pinch" gestures (zooming in or out) stops working.

Since I don't need any custom handling for pinch, I tried to disable the event recognizer like this:

hammer.get("pinch").set({enable: false});

No luck. The following jsfiddle illustrates the problem.

How can I keep my "swipe" handlers and let the browser do its job on pinch?


Solution

  • As it is pointed out in this question

    {touchAction : "auto"}
    

    is the way to go. Here is the corrected jsfiddle.