[英]How to prevent page scrolling when pinch-zooming with Pointer Event?
我有允许放大和缩小图像的功能,如果没有可滚动的父元素,它可以正常工作。 但是当有一个可滚动的父级时,它就不能正常工作。
事情是touch-action: none
不能直接使用,因为它会阻止页面滚动,但我想允许用户只有在一个手指按下时才滚动页面,如果两根手指按下则允许缩放图像下。
这很奇怪,但下面的代码不起作用:
let fingerCount; // Assume that it has the right value
element.addEventListener("pointerdown", e => {
if (fingerCount === 2) {
// This line will be ignored
element.style.touchAction = "none";
}
});
有没有办法结合页面滚动和捏缩放?
哦,我又年轻又傻))我必须这样做:
// This line has to be outside of `pointerdown`
element.style.touchAction = "pan-y";
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.