Created
September 19, 2017 17:11
-
-
Save dabit3/a0fa8a46252f38f3a84e65ccd847d928 to your computer and use it in GitHub Desktop.
Animated login screen
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
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