Created
February 6, 2017 13:29
-
-
Save mariodev12/ce226ef75967fa61d4ec5d077a78422a 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
/** | |
* Sample React Native App | |
* https://github.com/facebook/react-native | |
* @flow | |
*/ | |
import React, { Component } from 'react'; | |
import { | |
AppRegistry, | |
StyleSheet, | |
Text, | |
View, | |
Animated, | |
Dimensions | |
} from 'react-native'; | |
const {width, height} = Dimensions.get('window'); | |
export default class animationTutorial extends Component { | |
constructor(){ | |
super() | |
this.state = { | |
animate: new Animated.Value(30), | |
animateXY: new Animated.ValueXY({x: 0, y: 0}), | |
radius: new Animated.Value(0) | |
} | |
} | |
componentWillMount () { | |
Animated.sequence([ | |
Animated.timing(this.state.animateXY, { | |
toValue: {x: height / 2, y: 0}, | |
duration: 6000 | |
}), | |
Animated.timing(this.state.animate, { | |
toValue: 60, | |
duration: 6000 | |
}), | |
Animated.timing(this.state.radius, { | |
toValue: 40, | |
duration: 2000 | |
}) | |
]).start() | |
} | |
render() { | |
return ( | |
<View style={styles.container}> | |
<Animated.View | |
style={ | |
{ | |
width: this.state.animate, | |
height: this.state.animate, | |
backgroundColor: '#fabada', | |
position: 'absolute', | |
top: this.state.animateXY.x, | |
left: this.state.animateXY.y, | |
borderRadius: this.state.radius | |
} | |
} | |
/> | |
</View> | |
); | |
} | |
} | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
justifyContent: 'center', | |
alignItems: 'center', | |
backgroundColor: '#F5FCFF', | |
}, | |
welcome: { | |
fontSize: 20, | |
textAlign: 'center', | |
margin: 10, | |
}, | |
instructions: { | |
textAlign: 'center', | |
color: '#333333', | |
marginBottom: 5, | |
}, | |
}); | |
AppRegistry.registerComponent('animationTutorial', () => animationTutorial); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment