diff --git a/src/templates/core/base.html b/src/templates/core/base.html index 1767754..276b264 100644 --- a/src/templates/core/base.html +++ b/src/templates/core/base.html @@ -98,6 +98,22 @@ } } }()); + + // iOS Safari auto-zooms when focusing an // + // whose font-size is < 16px, and does NOT auto-zoom back out on blur. + // Briefly toggling maximum-scale=1.0 on the viewport meta forces iOS to + // reset to 1:1; reverting after 100ms restores the default content so + // users can still pinch-zoom manually elsewhere on the page. + (function () { + var vp = document.querySelector('meta[name="viewport"]'); + if (!vp) return; + var base = vp.getAttribute('content'); + document.addEventListener('focusout', function (e) { + if (!e.target.matches || !e.target.matches('input, textarea, select')) return; + vp.setAttribute('content', base + ', maximum-scale=1.0'); + setTimeout(function () { vp.setAttribute('content', base); }, 100); + }); + }());