Skip to content

Instantly share code, notes, and snippets.

@unruthless
Created April 28, 2014 15:53
Show Gist options
  • Save unruthless/11376185 to your computer and use it in GitHub Desktop.
Save unruthless/11376185 to your computer and use it in GitHub Desktop.
Prevent pinch-to-zoom on Win8/Chrome tablet
(function () {
'use strict';
function preventPinchToZoom(event) {
if (event.touches.length >= 2) {
event.stopPropagation();
event.preventDefault();
}
}
document.addEventListener('touchmove', preventPinchToZoom, false);
}());
@unruthless
Copy link
Author

Useful when prototyping a non-web interface using web technologies.

I'm sure there's a better way to do this - feedback and pull requests welcome!

@Mr0grog
Copy link

Mr0grog commented Apr 28, 2014

Does it need to be JS? I think adding user-scalable=no to the viewport meta tag would solve this, too, right? (dunno about Win8)

e.g.

<meta name="viewport" content="initial-scale=1.0,user-scalable=no,maximum-scale=1" />

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment