We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
背景
需求
The text was updated successfully, but these errors were encountered:
目前看没有很好的解决方案,建议是控制 longPress 的元素,尽量控制在较小的元素范围内
Sorry, something went wrong.
我的解决方法是:
如下:
const useXXX = (longPressCb, targetRef) => { const status = useRef(false) useLongPress(longPressCb, targetRef, { onClick() { status.current = true }, onLongPressEnd() { status.current = false } }) const clickHandler = (cb) => { return (...rest) => { if (status.current) { cb(...rest) } } } return { clickHandler } }
<Parent onClick={clickHandler(() => { console.log('你的处理') })}></Parent>
能解决,可以把 useLongPress 的事件传递方式改为捕获,然后在 useLongPress 监听的元素上的事件 通过 event.stopImmediatePropagation() 阻止捕获 应该能解决。
这个我们支持一下
crazylxr
No branches or pull requests
背景
需求
The text was updated successfully, but these errors were encountered: