react-native-swipe-gestures
react-native-swipe-gestures copied to clipboard
Prevent unused directions being blocked.
Hi there,
I am making good use of the package at the moment however there seems to be an 'issue' or in my case likely an oversight. Most situations I am only applying a behaviour to one or 2 of the directions available, for example I am making use of left and right swipe in conjunction with a sliding pane component, however the gestures are blocking the regular up and down ScollView/ListView from being able to scroll up and down (forces them to 2 fingers). Even though I am omitting anything to do with the Swipe Up & Down, it seems those are still reserved (for lack of a better word) by the package regardless of whether they are used or not.
Is there a way to free up the unused gestures to perform their normal behaviour?
Thanks
+1 Same here.
However, You can try my fork: https://github.com/thegamenicorus/react-native-swipe-gestures. I've add some configuration for enable/disable gesture direction.
<GestureRecognizer
onSwipeLeft={this.doSomethingWithSwipeLeft}
config={{
detectSwipeUp: false,
detectSwipeDown: false,
detectSwipeRight: false
}}
>
//..list view
</GestureRecognizer>
It's ok for my project. Hope it help.
@thegamenicorus this worked a charm for us, thanks! :)
It will be really nice to include that solution in this repo
@thegamenicorus That is exactly what I have been looking for, thank you for making that so easy.
@thegamenicorus Perfect! Thanks!
@thegamenicorus Thanks for your tweak, I have discovered a small bug however, if you disable a direction in one instance of GestureRecognizer it appears to be disabled for other instances too - I discovered this when trying to essentially make a way of swiping between screens and could only go in one direction until I stopped it being disabled on the first screen, the simple fix was to just not handle the opposite direction if it was not needed, but just thought it might be useful to know
@thegamenicorus worked perfectly thanks! Would be nice to have this in the actual npm maintained repo.
For anyone looking out for a solution, you can try this library: https://www.npmjs.com/package/rn-swipe-gestures It's basically a clone of react-native-swipe-gestures. The only difference is you can add props to the config such as detectSwipeUp, detectSwipeDown, etc. This will solve your problem.