Skip to content

Instantly share code, notes, and snippets.

@Fischaela
Last active March 24, 2017 13:48
Show Gist options
  • Select an option

  • Save Fischaela/7ddbc5bdae812d15b1d771d5de862ee3 to your computer and use it in GitHub Desktop.

Select an option

Save Fischaela/7ddbc5bdae812d15b1d771d5de862ee3 to your computer and use it in GitHub Desktop.
ReactVR Component – Animated translation – transformOrigin?
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>
);
}
};
@mikearmstrong001
Copy link

mikearmstrong001 commented Mar 24, 2017

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

transform: [
            {translate: [1.5, 0, 3]},
            {scaleX: this.state.animatedScale},
            {scaleY: this.state.animatedScale},
            {translate: [-1.5, 0, -3]},
          ],

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment