Last active
June 12, 2019 09:36
-
-
Save panvourtsis/1596a2f16763df3a0451267d2d6def5d to your computer and use it in GitHub Desktop.
RN-PanResponser
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import React from 'react'; | |
import { Animated } from 'react-native'; | |
const PanExample = () => { | |
const panResponder = PanResponder.create({ | |
onStartShouldSetPanResponder: () => true, // we are enabling pan responder on start with this. So now we can listen tap and move | |
onPanResponderMove: (evt, gestureState) => { | |
// here we are listening every move | |
// evt and gestureState simply returns the x,y of the movement position | |
console.log('yes we are moving', gestureState.dy, gestureState.dx); | |
}, | |
onPanResponderRelease: (evt, gestureState) => { | |
// When user release the gesture we get the last x,y of that movement | |
console.log('just released', gestureState.dy, gestureState.dx); | |
}, | |
}); | |
} | |
return <Animated.View {...panResponder.panHandlers} />; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment