Last Updated: February 25, 2016
·
1.172K
· benjamincharity

Lock iOS zoom until a user manually zooms.

// 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);
}