-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
onTouchMove不能阻止滑动穿透问题 #3980
Comments
欢迎提交 Issue~ 如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏 如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。 Good luck and happy coding~ |
@ItxiaoDz 我做过类似的操作 handleTouchMove = (e) => {
e.preventDefault()
e.stopPropagation()
}
// jsx
<View className={classString} onTouchMove={this.handleTouchMove}> 我这里测试没问题的, iPhone8p |
Hello~ 您的问题楼上已经有了确切的回答,如果没有更多的问题这个 issue 将在 15 天后被自动关闭。 如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。 Good luck and happy coding~ |
@IFmiss 嗯,确实这样写可以 |
我写的是函数组件,还是不能阻止页面滚动 const handleTouchMove = (event: ITouchEvent) => {
console.log(1)
event.stopPropagation()
event.preventDefault()
return
} |
组织swiper左右滑动,但是不阻止上下页面滑动,请问这个要怎么处理呢 |
|
麻烦问一哈, 可以动态控制这个阻止滑动吗 |
这个问题依然存在,不能阻止整个页面page的滚动 |
根据问题5909中的回答,onTouchMove 应该被编译成小程序中 catchtouchmove 方法了,当前版本不可以动态控制。 |
一层View catchMove ,里面放个ScrollView |
View catchMove 下的 ScrollView 无法滚动 |
问题描述
我们在做应用时,需要做一个自定义弹窗,带背景蒙层的。使用这个自定义弹窗的页面有可能是可以滚动的,本来设计是弹窗出现后,蒙层后面的页面不能进行滚动的。实现方式是在蒙层的View中定义onTouchMove事件,并在事件处理方法中使用e.stopPropagation();阻止事件冒泡。但是经过测试,h5不存在问题,但是微信小程序中,滑动事件仍会向父组件传递了。原来写原生小程序时,可以用catchtouchmove处理的,但是Taro框架又不能使用catchtouchmove。
复现步骤
https://github.com/ItxiaoDz/taro-demo
master的最新一次提交可以复现这个问题。
“打开底层页面可以滚动的蒙层”这个按钮是复现我描述的问题的。
“打开能阻止底层页面滚动的蒙层”这个按钮我是强行使用了catchtouchmove,看最后编译出来的效果,后面的处理函数框架实际是没有将它当一个方法处理的,所以执行是会有警告:
期望行为
我觉得可以有3中处理方式:
报错信息
系统信息
补充信息
The text was updated successfully, but these errors were encountered: