wuba / wuba/react-native-echarts
使用react-native-gesture-handler时,长按 手势结束后不会发送mouseup事件到zr
Nobody has claimed this yet.
- Dominant language
- TypeScript
- Stars
- 967
- Forks
- 35
- PR merge metrics
- No merged PRs in 30d
Description
Describe the bug
A clear and concise description of what the bug is.
To Reproduce
Steps to reproduce the behavior:
如题,组件设置 useRNGH 之后,在画布长按即可
Expected behavior
长按 手势结束后应该发送mouseup事件
Screenshots
no
Desktop (please complete the following information):
无关
Smartphone (please complete the following information):
无关
Additional context
我已经了解问题是如何发生的,当前发送对应事件的代码如下
https://github.com/wuba/react-native-echarts/blob/8b7115376f650eb2318fc8820460b5b924094205/src/components/RNGestureHandler.tsx#L17-L36
这里使用了onBegin而不是onStart应该是有意为之,可能是为了其它两个手势没有识别时也能发送mousedown事件
但根据文档
onEnd(callback)
Set the callback that is being called when the gesture that was recognized by the handler finishes. It will be called only if the handler was previously in the active state.
设置手势处理程序识别完成后要调用的回调函数。仅当处理程序之前处于激活状态时才会调用此回调函数。
onEnd只有在激活时才执行回调,而长按不会激活Gesture.Pan
解决方案很简单,只需要把onEnd改为onFinalize即可。这样会在Gesture.Tap手势激活时发送两次mouseup,但我们应该直接让Gesture.Tap手势在onEnd回调中只发送'click'事件,同时移除onStart回调。
需要我提交一个PR吗
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start in src/components/RNGestureHandler.tsx at the gesture callbacks linked in the issue, and read the React Native Gesture Handler behavior for onEnd and onFinalize. Verify the long-press path emits mouseup and that tap handling does not emit duplicate mouseup events; done means the event sequence matches the expected behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react-native, typescript
- Domain
- mobile
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100