iOS double-click Page Zoom Disable

Source: Internet
Author: User

The mobile device has been upgraded to IOS10 and found that its own Safari browser no longer recognizes Meta viewport . We used to use this tag to let the browser disable zooming. The apple~~ of Evil

Before the iOS10, it was all through.

<meta name="viewport" content="width=device-width,initial-scale=1.0, Maximum-scale=1.0,minimum-scale=1.0,user-scalable=no ">

To force the phone browser to be scaled, but safari no longer recognizes this meta tag after upgrading to IOS10. So you have to use JS to hack a bit:
To disable two-finger scaling:

Document.documentElement.addEventListener (' Touchstart ', function (event) {
if (Event.touches.length > 1) {
Event.preventdefault ();
}
}, false);

Disable Finger double-click Zoom:

var lasttouchend = 0;
Document.documentElement.addEventListener (' touchend ', function (event) {
var now = Date.now ();
if (now-lasttouchend <= 300) {
Event.preventdefault ();
}
Lasttouchend = Now;
}, false);

If in the IOS10 Safari set up viewport , in fact, double-click amplification is not in effect, so personally think the iOS10 on the better solution is set viewport first, and then use JS to disable the two-finger zoom, no longer set to disable double-click Scaling.

The author of this solution also gives a hint that if any of the child elements of the touch event stopPropagation is set to block event bubbling, it may still fail, and in iOS10 your input box font should not be less than 16px, Otherwise iOS might force the zoom in when the input box gets focus.

Original address: Http://stackoverflow.com/questions/37808180/disable-viewport-zooming-ios-10-safari

iOS double-click Page Zoom Disable

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.