ios移动端禁止双指缩放功能

在实际开发中,我们禁止缩放的实现方式:

1.meta设置:

<meta name="viewport"  content="width=device-width,height=device-height, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0, user-scalable=0" /> ,user-scalabel=no或者user-scalabel=yes(yes是可以缩放,no或者0是不能缩放)

在ios10以上的系统中,并不支持meta标签,需要我们通过脚本实现:

window.addEventListener(
"touchmove",
function(event) {
if (event.scale !== 1) {
event.preventDefault();
}
},
{ passive: false }
);
注意:禁用双指缩放后,scroll事件需要重新绑定,滚动条的事件监听touchmove,touchstart,touchend;
 
原文地址:https://www.cnblogs.com/starryqian/p/10212285.html