React-native-gesture-handler: How to stop propagate touch event to parent responder

Created on 28 Sep 2019  路  2Comments  路  Source: software-mansion/react-native-gesture-handler

Hello everybody,

I have a scrollview that is wrapped by a TapGestureHandler to create a new view when user tap on scrollview at touch position.
When user tap a sub view on scrollview I will render a RectButton on Scrollview to allow user delete this view from scrollview.

Current behavior
Both RectButton and TapGestureHandler handle touch event when user tap on RectButton

Expected behavior
TapGestureHandler should not handle touch event when user tap RectButton.

So I would like to know how to make RectButton stop sending touch event to TapGestureResponder. Thanks in advance.

My environment:
react-native-gesture-handler: 1.4.1
react-native: 0.60.5

Most helpful comment

Thank for your reply.

To resolve this issue, I have to use other TapGestureHandler and check touch location inside view's rect instead of using built-in RectButton.
I just think a touchable child view (in my case is RectButton) should consume touch event and stop propagating touch event to parent by default.

All 2 comments

Hi,

As stated here, only one gesture handler is in active state at a time. Are you checking that the event is in Active state?

<TapGestureHandler
  onHandlerStateChange={e => 
    if(e.nativeEvent.state === State.ACTIVE){
      // handle tap
    }
>

Thank for your reply.

To resolve this issue, I have to use other TapGestureHandler and check touch location inside view's rect instead of using built-in RectButton.
I just think a touchable child view (in my case is RectButton) should consume touch event and stop propagating touch event to parent by default.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chrisdrackett picture chrisdrackett  路  4Comments

jacobrosenskold picture jacobrosenskold  路  3Comments

brunolemos picture brunolemos  路  3Comments

brunolemos picture brunolemos  路  3Comments

rt2zz picture rt2zz  路  4Comments