(noob) Moaaar complete example
polmoneys opened this issue · comments
aloha from Barcelona
is there a chance you could share how to listen to 4 events (swipeUp,swipeDown,swipeRight,swipeLeft) and trigger a different response for each?
I've tried to listen to the evt onPanResponderRelease and switch between the values with no success :(
TIA
@polmoneys if you still need help this is what I did to handle the different gestures:
componentDidMount = () => {
this._panResponder = PanResponder.create({
onMoveShouldSetResponderCapture: () => true,
onMoveShouldSetPanResponderCapture: () => true,
onStartShouldSetPanResponder: this._handleStartShouldSetPanResponder,
onMoveShouldSetPanResponder: this._handleMoveShouldSetPanResponder,
onPanResponderGrant: this._handlePanResponderGrant,
onPanResponderMove: this._handlePanResponderMove,
onPanResponderRelease: this._handlePanResponderEnd,
onPanResponderTerminate: this._handlePanResponderEnd,
});
}
_handlePanResponderMove = (e: Object, gestureState: Object) => {
let sgs = newSimpleGesture(e, gestureState);
if (sgs.isSwipeRight()) {
console.log('is swipe right');
} else if (sgs.isSwipeLeft()) {
console.log('is swipe left')
}
Is not a complete example but it should give you a good idea.
@jqn thanks for your input but can't make it work :(
I'll take another round tomorrow...
YAY IT WORKED ! !