React-native-gesture-handler: multi-touch handlers in android

Created on 26 Oct 2017  ·  4Comments  ·  Source: software-mansion/react-native-gesture-handler

By multi-touch views I mean something like:

<View
    onTouchStart={() => { console.log('pressing left button'); }}
    onTouchEnd={() => { console.log('releasing left button'); }}
>
    {...}
</View>
<View
    onTouchStart={() => { console.log('pressing right button'); }}
    onTouchEnd={() => { console.log('releasing right button'); }}
>
    {...}
</View>

The idea is the user has to hold both the left and right button for something to be triggered (the bit that waits for both to be pressed isn't in the example above, but I want to make clear that the two touchables are separate elements).

This works fine on iOS but not on Android: related to https://github.com/facebook/react-native/issues/10068.

So, was hoping I could use this library to work around that issue. Doesn't seem to work however -- replacing the above with

<BaseButton
  onActiveStateChange={(isActive) => {
    if (isActive) {
      console.log('pressing left button');
    } else {
      console.log('releasing left button');
    }
  }}
>
  {...}
</BaseButton>
<BaseButton
  onActiveStateChange={(isActive) => {
    if (isActive) {
      console.log('pressing right button');
    } else {
      console.log('releasing right button');
    }
  }}
>
  {...}
</BaseButton>

But this results in the same issue as using View: once one button is held, pressing the other triggers the original button's handler (on Android).

Is there any way to use simultaneousHandlers here?

Feature request

Most helpful comment

Hey @yossarin @rgangopadhya

Just letting you know we've merged PR that adds support for that: https://github.com/kmagiera/react-native-gesture-handler/commit/4036fba2fbc7e05d1fea340676a2975594936e8c

The demo is here: https://twitter.com/kzzzf/status/1015907930649055233

After quite a long time I am happy to finally close this issue. If you have any questions or want to discuss this further feel free to reopen it or create a new issue.

All 4 comments

Hello,

I am curious what is the obstacle with implementing multi-touch handlers in android?
(Obviously I need this feature)

I am asking because I want to help with this issue, maybe you have some pointers for me? :) @kmagiera

Hey @yossarin @rgangopadhya

Just letting you know we've merged PR that adds support for that: https://github.com/kmagiera/react-native-gesture-handler/commit/4036fba2fbc7e05d1fea340676a2975594936e8c

The demo is here: https://twitter.com/kzzzf/status/1015907930649055233

After quite a long time I am happy to finally close this issue. If you have any questions or want to discuss this further feel free to reopen it or create a new issue.

I'm still having this issue on Android but have no issues on iOS. I'm on the latest version. Any suggestions?

Was this page helpful?
0 / 5 - 0 ratings