Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save iskenxan/6960507be90561c17b8e27ffb92b262c to your computer and use it in GitHub Desktop.
Save iskenxan/6960507be90561c17b8e27ffb92b262c to your computer and use it in GitHub Desktop.
this.mainPanResponder = PanResponder.create({
onStartShouldSetPanResponder: () => true,
onMoveShouldSetPanResponder: () => true,
onPanResponderMove: Animated.event([
null, { dx: this.mainPosition.x, dy: this.mainPosition.y }
]),
onPanResponderGrant: (event, gesture) => {
this.mainPosition.setOffset({
x: this.mainPosition.x._value,
y: this.mainPosition.y._value
});
this.mainPosition.setValue({ x: 0, y: 0 });
},
onPanResponderRelease: (e, gesture) => {
this.mainPosition.flattenOffset();
if (gesture.dy < -150) {
const y = gesture.dy + this.panelY + this.scrollY;
this.addCard(y)
}
this.mainPosition.setValue({ x: 0, y: 0 });
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment