TapGestureHandler 的 onGestureEvent 永远不会触发吗?
Does onGestureEvent of TapGestureHandler never fire?
下面是问题的 Snack - https://snack.expo.io/@noitidart/tapgesturehandler-ongestureevent
onGestureEvent
for TapGestureHandler
永远不会触发吗?文档没有说清楚。这似乎发生在我身上:
import Reanimated from 'react-native-reanimated';
const handleStateChange = () => console.log('state changed');
const handleGestureEvent = () => console.log('got gesture event');
<TapGestureHandler
onHandlerStateChange={handleStateChange}
onGestureEvent={handleGestureEvent}>
<Reanimated.View
style={{ width: 100, height: 100, backgroundColor: 'green' }}
/>
</TapGestureHandler>
你会看到点击它永远不会触发 ('gesture event')
我 运行 也参与其中,手势处理程序中关于离散手势与连续手势的文档提到了它:
Keep in mind that onGestureEvent is only generated in continuous gesture handlers and shouldn't be used in the TapGestureHandler and other discrete handlers.
来源:https://docs.swmansion.com/react-native-gesture-handler/docs/about-handlers
这非常令人困惑,因为在 Reanimated 中使用 TapGestureHandler 的示例似乎使用了 onGestureEvent,但我发现自己处理状态更改是可行的方法。
好消息是,由于它是一种独立的手势,因此管理起来非常简单。
下面是问题的 Snack - https://snack.expo.io/@noitidart/tapgesturehandler-ongestureevent
onGestureEvent
for TapGestureHandler
永远不会触发吗?文档没有说清楚。这似乎发生在我身上:
import Reanimated from 'react-native-reanimated';
const handleStateChange = () => console.log('state changed');
const handleGestureEvent = () => console.log('got gesture event');
<TapGestureHandler
onHandlerStateChange={handleStateChange}
onGestureEvent={handleGestureEvent}>
<Reanimated.View
style={{ width: 100, height: 100, backgroundColor: 'green' }}
/>
</TapGestureHandler>
你会看到点击它永远不会触发 ('gesture event')
我 运行 也参与其中,手势处理程序中关于离散手势与连续手势的文档提到了它:
Keep in mind that onGestureEvent is only generated in continuous gesture handlers and shouldn't be used in the TapGestureHandler and other discrete handlers.
来源:https://docs.swmansion.com/react-native-gesture-handler/docs/about-handlers
这非常令人困惑,因为在 Reanimated 中使用 TapGestureHandler 的示例似乎使用了 onGestureEvent,但我发现自己处理状态更改是可行的方法。 好消息是,由于它是一种独立的手势,因此管理起来非常简单。