我已经成功禁用了ios中的缩放和捏缩放,如下所示:
document.addEventListener("gesturestart", function (e) { e.preventDefault(); document.body.style.zoom = 0.99; });
document.addEventListener("gesturechange", function (e) { e.preventDefault(); document.body.style.zoom = 0.99; });
document.addEventListener("gestureend", function (e) { e.preventDefault(); document.body.style.zoom = 1; });
但是我发现页面正在滚动时,我可以再次放大 如果页面不滚动但滚动时中断/不捕获事件,则上面的解决方案效果很好。
我还尝试过使用jQuery油门/反跳来矫kill过正,就像这样:
$(window).scroll($.debounce(250, function() {
console.log('Finished Scrolling');
document.getElementById('resetViewport').setAttribute('content', 'width=device-width,height=device-height,initial-scale=1,user-scalable=no,minimum-scale=1,maximum-scale=1');
var viewportmeta = document.querySelector('meta[name="viewport"]');
if (viewportmeta) {
viewportmeta.content = 'width=device-width,height=device-height,initial-scale=1,user-scalable=no,minimum-scale=1,maximum-scale=1';
document.body.addEventListener('gesturestart', function() {
viewportmeta.content = 'width=device-width,height=device-height,initial-scale=1,user-scalable=no,minimum-scale=1,maximum-scale=1';
}, false);
document.addEventListener('gesturestart', function() {
viewportmeta.content = 'width=device-width,height=device-height,initial-scale=1,user-scalable=no,minimum-scale=1,maximum-scale=1';
}, false);
}
}));
但是那没有用。 有个主意吗?