Skip to content

Instantly share code, notes, and snippets.

@dabit3
Created September 19, 2017 17:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dabit3/a0fa8a46252f38f3a84e65ccd847d928 to your computer and use it in GitHub Desktop.
Save dabit3/a0fa8a46252f38f3a84e65ccd847d928 to your computer and use it in GitHub Desktop.
Animated login screen
class LoginScreen extends React.Component {
state = {
loggedIn: false,
}
animatedValue = new Animated.Value(height);
componentWillReceiveProps() {
const { isLoggedIn } = this.props.userConfig.user;
if (isLoggedIn) {
animate();
}
}
componentDidMount() {
setTimeout(() => {
this.setState({ loggedIn: true, })
this.animate();
}, 2000)
}
animate = () => {
Animated.timing(
this.animatedValue,
{
duration: 750,
toValue: -height,
useNativeDriver: true
}
).start();
}
render() {
return (
<Animated.View style={{
width,
height,
backgroundColor: 'red',
position: 'absolute',
/* top: this.animatedValue, */
transform: [
{
translateY: this.animatedValue
}
],
left: 0
}} />
)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment