Skip to content

Instantly share code, notes, and snippets.

@panvourtsis
Last active June 12, 2019 09:36
Show Gist options
  • Save panvourtsis/1596a2f16763df3a0451267d2d6def5d to your computer and use it in GitHub Desktop.
Save panvourtsis/1596a2f16763df3a0451267d2d6def5d to your computer and use it in GitHub Desktop.
RN-PanResponser
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