-
-
Couldn't load subscription status.
- Fork 1k
Fix interactions with NativeViewGestureHandler #1034
New issue
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
Conversation
Expose `NativeViewGestureHandler ._handlerTag` on `ref` to enable interaction configuration.
|
@jakub-gonet any plans on merging this? |
|
#963 Originally posted by @ShaMan123 in #963 (comment) |
|
updated description |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good except for one unused import. I'll commit it and merge after CI passes.
|
Would be nice to have this in a release :) |
### Context [`transformIntoHandlerTags`](https://github.com/software-mansion/react-native-gesture-handler/blob/master/createHandler.js#L91) creates an array of valid refs based on the value of the property `_handlerTag` of each ref passed to `waitFor` or `simultaneousHandlers` prop. The filtered array is then sent to native for configuration. ### `NativeViewGestureHandler` In the case of `NativeViewGestureHandler` the `_handlerTag` is set on the `NativeViewGestureHandler` ref properly. **HOWEVER**, this value isn't passed to the ref of it's child. The child's ref is the one being passed back as the ref handler of the component. This makes sense. **However**, in order to configure interactions on a different handler one would need to pass the `NativeViewGestureHandler` ref as part of `waitFor` or `simultaneousHandlers` prop. This is **IMPOSSIBLE** because the `NativeViewGestureHandler` ref isn't exposed. The child's ref is passed instead and is filtered out by `transformIntoHandlerTags` due to the lack of `_handlerTag` property, making it completely useless. ### The End This PR fixes the mentioned problem by setting the `_handlerTag` property on the `NativeViewGestureHandler` **child's ref** so when it is passed to `waitFor` or `simultaneousHandlers` it is treated as if it were a genuine gesture handler. Co-authored-by: Jakub <[email protected]>
|
Can someone provide a code example of how to use this? I am still having trouble with |
Context
transformIntoHandlerTagscreates an array of valid refs based on the value of the property_handlerTagof each ref passed towaitFororsimultaneousHandlersprop. The filtered array is then sent to native for configuration.NativeViewGestureHandlerIn the case of
NativeViewGestureHandlerthe_handlerTagis set on theNativeViewGestureHandlerref properly.HOWEVER, this value isn't passed to the ref of it's child. The child's ref is the one being passed back as the ref handler of the component. This makes sense.
However, in order to configure interactions on a different handler one would need to pass the
NativeViewGestureHandlerref as part ofwaitFororsimultaneousHandlersprop.This is IMPOSSIBLE because the
NativeViewGestureHandlerref isn't exposed.The child's ref is passed instead and is filtered out by
transformIntoHandlerTagsdue to the lack of_handlerTagproperty, making it completely useless.The End
This PR fixes the mentioned problem by setting the
_handlerTagproperty on theNativeViewGestureHandlerchild's ref so when it is passed towaitFororsimultaneousHandlersit is treated as if it were a genuine gesture handler.