Created
October 17, 2018 06:59
-
-
Save 35d/dc76d8d469921742c8e6a4526c37294f to your computer and use it in GitHub Desktop.
Lottie Animation Sample
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
// @flow | |
import React, { Component } from 'react'; | |
import { StyleSheet, View } from 'react-native'; | |
import LottieView from 'lottie-react-native'; | |
import loading from '../assets/lottie/loading.json'; | |
const styles = StyleSheet.create({ | |
container: { | |
flex: 1, | |
backgroundColor: '#333333', | |
}, | |
}); | |
export default class LottieAnimation extends Component { | |
loadingAnimation: LottieView; | |
componentDidMount() { | |
if (this.loadingAnimation) this.loadingAnimation.play(); | |
} | |
render() { | |
return ( | |
<View style={styles.container}> | |
<LottieView | |
style={{ | |
width: 100, | |
height: 120, | |
paddingTop: 90, | |
alignSelf: 'center', | |
}} | |
ref={(refs) => { | |
this.loadingAnimation = refs; | |
}} | |
source={loading} | |
/> | |
</View> | |
); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment