Skip to content

Instantly share code, notes, and snippets.

@Karthik-B-06
Created May 17, 2021 08:02
Show Gist options
  • Save Karthik-B-06/d6b67ae77308ce2b90658e3073c1bdac to your computer and use it in GitHub Desktop.
Save Karthik-B-06/d6b67ae77308ce2b90658e3073c1bdac to your computer and use it in GitHub Desktop.
<TapGestureHandler
onHandlerStateChange={(event) => {
if (event.nativeEvent.state === State.BEGAN) {
spring(springValue, {
toValue: 1,
mass: 1,
damping: 20,
stiffness: 150,
overshootClamping: false,
restSpeedThreshold: 0.001,
restDisplacementThreshold: 0.001,
}).start();
} else if (event.nativeEvent.state === State.END) {
spring(springValue, {
toValue: 0,
mass: 1,
damping: 20,
stiffness: 150,
overshootClamping: false,
restSpeedThreshold: 0.001,
restDisplacementThreshold: 0.001,
}).start();
// The function you want to perform at the end of the Gesture
} else {
spring(springValue, {
toValue: 0,
mass: 1,
damping: 20,
stiffness: 150,
overshootClamping: false,
restSpeedThreshold: 0.001,
restDisplacementThreshold: 0.001,
}).start();
}
}}
>
<Animated.View
style={[
{
transform: [
{
scale: interpolate(springValue, {
inputRange: [0, 0.5],
outputRange: [1, 0.95],
}),
},
],
},
]}
>
{ /* Your Component */ }
</Animated.View>
</TapGestureHandler>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment