react native detect swipe
this.touchY = e.nativeEvent.pageY} onTouchEnd={e => { if (this.touchY - e.nativeEvent.pageY > 20) console.log('Swiped up') }} style={{height: 300, backgroundColor: '#ccc'}} />
Here is what the above code is Doing:
1. We’re using the onTouchStart event to store the Y position of the touch event.
2. We’re using the onTouchEnd event to compare the Y position of the touch event to the Y position of the touch start event.
3. If the difference between the two is greater than 20, we know that the user has swiped up.