alibaba / hooks

A high-quality & reliable React Hooks library. https://ahooks.pages.dev/
https://ahooks.js.org/
MIT License
14.02k stars 2.71k forks source link

useLongPress的moveThreshold支持对onclick生效 #2166

Open dislido opened 1 year ago

dislido commented 1 year ago

移动端上下滑动页面时,松手后会触发onclick moveThreshold似乎只对longPress生效,是否可以添加对onclick的支持或解决方案

dislido commented 1 year ago

原本的onclick事件本身不会在屏幕滑动时触发,应该是因为useLongPress使用mouseleave/touchend模拟click导致触发了事件

liuyib commented 1 year ago

和这个问题差不多:https://github.com/alibaba/hooks/pull/2133 快速滑动时,类似于点击了,导致 moveThreshold 生效不了,目前来看是这样的原因,还在进一步确认中。

CYeas commented 1 year ago

是有一点像?但我那边其实不用速度很快也能复现,而且触发的是longpress,只是可能手指不能上下滑动。这边debug的情况就是在slide的时候横向滑动被native拦截了,马上触发了touchcancel,webview与手指的相对位置并没有变化,所以浏览器没有认为是move,touchmove没有触发,在响应的上下文去debug event的position实际上也没有变化,所以那个pr就处理了下touchcancel的case

liuyib commented 1 year ago

之前我好像确实理解错了,我再排查下这个问题

xmsz-stu commented 11 months ago

现在情况如何了