Created
November 16, 2017 05:11
-
-
Save Shadid12/f5e67438ac3511c939ed82b318b18c3b to your computer and use it in GitHub Desktop.
React Simple Animation
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
import React from 'react'; | |
import { | |
StyleSheet, | |
Text, | |
View, | |
TouchableOpacity, | |
Animated, | |
Easing | |
} from 'react-native'; | |
export default class App extends React.Component { | |
constructor(props) { | |
super(props); | |
this.animatedValue = new Animated.Value(25); | |
} | |
_animate = () => { | |
Animated.timing(this.animatedValue, { | |
toValue: 100, | |
duration: 1000, | |
easing: Easing.bounce | |
}).start(); | |
}; | |
render() { | |
const animatedStyle = {height: this.animatedValue}; | |
return ( | |
<View> | |
<TouchableOpacity style={styles.container} onPress={this._animate}> | |
<Animated.View style={[styles.box, animatedStyle]}> | |
<Text style={styles.text}>Facebook Login</Text> | |
</Animated.View> | |
</TouchableOpacity> | |
</View> | |
) | |
} | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
}, | |
box: { | |
backgroundColor: '#33a1d1', | |
width: 100, | |
height: 25 | |
}, | |
text: { | |
color: '#fff' | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment