Last active
March 24, 2017 13:48
-
-
Save Fischaela/7ddbc5bdae812d15b1d771d5de862ee3 to your computer and use it in GitHub Desktop.
ReactVR Component – Animated translation – transformOrigin?
This file contains hidden or 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
| class UI extends React.Component { | |
| constructor(props) { | |
| super(props); | |
| this.buttons = this.props.buttonConfig; | |
| this.state = { | |
| animatedOpacity: new Animated.Value(1), | |
| animatedScale: new Animated.Value(1), | |
| }; | |
| } | |
| componentWillMount() { | |
| this.fadeOut(); | |
| } | |
| fadeOut() { | |
| Animated.parallel([ | |
| Animated.timing( | |
| this.state.animatedOpacity, | |
| { | |
| toValue: 0.25, | |
| duration: 250, | |
| delay: 5000, | |
| } | |
| ), | |
| Animated.timing( | |
| this.state.animatedScale, | |
| { | |
| toValue: 0.000001, | |
| duration: 250, | |
| delay: 5000, | |
| easing: Easing.quad, | |
| } | |
| ), | |
| ]).start(); | |
| } | |
| render () { | |
| const buttons = this.buttons.map((button) => | |
| <Button/> | |
| ); | |
| return ( | |
| <Animated.View | |
| style={{ | |
| flexDirection: 'row', | |
| flexWrap: 'wrap', | |
| opacity: this.state.animatedOpacity, | |
| transform: [ | |
| {scaleX: this.state.animatedScale}, | |
| {scaleY: this.state.animatedScale}, | |
| {translate: [-1.5, 0, -3]}, | |
| ], | |
| width: 3, | |
| }} | |
| > | |
| {buttons} | |
| </Animated.View> | |
| ); | |
| } | |
| }; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Where do you want to scale around
all views should transform around 50% 50% by default but they layout at top, left
you will also need to reverse the transform after