Skip to content

Instantly share code, notes, and snippets.

@JoeM-RP
Last active Nov 5, 2019
Embed
What would you like to do?
const SCALE = {
// this defines the terms of our scaling animation.
getScaleTransformationStyle(animated: Animated.Value, startSize: number = 1, endSize: number = 0.99) {
const interpolation = animated.interpolate({
inputRange: [0, 1],
outputRange: [startSize, endSize],
});
return {
transform: [
{ scale: interpolation },
],
};
},
// This defines animation behavior we expext onPressIn
pressInAnimation(animated: Animated.Value, duration: number = 150) {
animated.setValue(0);
Animated.timing(animated, {
toValue: 1,
duration,
useNativeDriver: true,
}).start();
},
// This defines animatiom behavior we expect onPressOut
pressOutAnimation(animated: Animated.Value, duration: number = 150) {
animated.setValue(1);
Animated.timing(animated, {
toValue: 0,
duration,
useNativeDriver: true,
}).start();
},
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment