Skip to content

Instantly share code, notes, and snippets.

@JoeM-RP
Last active November 5, 2019 23:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save JoeM-RP/608c155f317a80634c2d1dfa4b962c2b to your computer and use it in GitHub Desktop.
Save JoeM-RP/608c155f317a80634c2d1dfa4b962c2b to your computer and use it in GitHub Desktop.
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