-
-
Save reime005/53626b084900dd7e72a93e391f020367 to your computer and use it in GitHub Desktop.
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
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