javascriptcssmobile-safariscaleios11.3

How to disable viewport zooming in iOS 11.3 safari?


I ve tried all (yes all!!!) the solutions from this question and nothing seems to be working with iOS 11.3?

Did someone had success with preventing pinch to zoom with ios 11.3? PS: I know that there are good reasons not to prevent pinch zooming... . But I have no choice. Many Thanks in Advance and sorry for my English.


Solution

  • Note that most of these options break lots of functionality and are bad for accessibility etc, etc, but some applications, in particular multi-touch PWAs need to disable these features. Use at own risk.

    With regards to the parent comment that they've tried all the solutions in the link, pay attention to the "Note that if any deeper targets call stopPropagation on the event, the event will not reach the document and the scaling behaviour will not be prevented by this listener."- this is key.

    Adding this script tag works on iOS 11.3 Safari (tested on iPhone SE)

    <script>
        document.addEventListener('touchmove',
            function(e) {
                e.preventDefault();
            }, {passive:false});
    </script>
    

    Of course, you'd then have to handle all touch inputs (which, if you're in need of a custom, multi-touch PWA, you really have to do anyway).