Franco Tassi
Franco Tassi

Reputation: 21

2017 last mobile Chrome Upgrade - How Disable double-tap ZOOM

I'we used, for long time, this (from Mr Evrim Persembe) :

function preventZoom(e){
    var t2 = e.timeStamp;
    var t1 = e.currentTarget.dataset.lastTouch || t2;
    var dt = t2 - t1;
    var fingers = e.touches.length;
    e.currentTarget.dataset.lastTouch = t2;

    if (!dt || dt > 500 || fingers > 1) return; // not double-tap

    e.preventDefault();
    e.target.click();
}
document.body.addEventListener('touchstart',preventZoom);

After last chrome upgrade doesn't works anymore. Anyone can help me?

Upvotes: 1

Views: 415

Answers (1)

Franco Tassi
Franco Tassi

Reputation: 21

In Firefox, and the older versions of Chrome (for example v50), the JavaScript works fine.

To use with the latest version I've solved it by using touch-action: manipulation into the CSS file:

body {
  touch-action: manipulation;
  ...
} 

Upvotes: 1

Related Questions