Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save benjamincharity/1602807 to your computer and use it in GitHub Desktop.
Save benjamincharity/1602807 to your computer and use it in GitHub Desktop.
This locks the viewport zoom until the user touches to zoom.
// lock the zoom unless the user is manually zooming
var viewportmeta = document.querySelector('meta[name="viewport"]');
if (viewportmeta) {
viewportmeta.content = 'width=device-width, minimum-scale=1.0, maximum-scale=1.0, initial-scale=1.0';
document.body.addEventListener('gesturestart', function () {
viewportmeta.content = 'width=device-width, minimum-scale=0.25, maximum-scale=1.6';
}, false);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment