Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
onEnd: (event, ctx) => {
// dragged 40 percent of the screen's width
const thresh = width * 0.4;
// how much the user moved the image horizontally
const diff = ctx.startX + event.translationX;
if (diff > thresh) {
// swiped right
onSnap({ right: true });
} else if (diff < -1 * thresh) {
// swiped left
onSnap({ right: false });
} else {
// no left or right swipe, so 'jump' back to the initial position
// withSpring is from 'react-native-reanimated'
x.value = withSpring(0);
y.value = withSpring(0);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment