How can I detect a left swipe on the entire screen in React Native?
Would it be necessary to use PanResponder or can it be done a little more easy?
There is an existing component react-native-swipe-gestures
for handling swipe gestures in up, down, left and right direction, see https://github.com/glepur/react-native-swipe-gestures
I've found that react-native-swipe-gestures
isn't stable (swipes works randomly on android) and react-native-gesture-handler
is overcomplicated (too much efforts to just add to project).
Simplified solution based on Kuza Grave's answer, who's solution works perfect and very simple:
<View onTouchStart={e=> this.touchY = e.nativeEvent.pageY} onTouchEnd={e => { if (this.touchY - e.nativeEvent.pageY > 20) console.log('Swiped up') }} style={{height: 300, backgroundColor: '#ccc'}} />
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With