lottie code example
Example 1: lottie animation github
dependencies {
implementation 'com.airbnb.android:lottie:$lottieVersion'
}
Example 2: github lottie
lottie.loadAnimation({
container: element, // the dom element that will contain the animation
renderer: 'svg',
loop: true,
autoplay: true,
path: 'data.json' // the path to the animation json
});
Example 3: lottie npm
import React from 'react'import Lottie from 'react-lottie';import * as animationData from './pinjump.json' export default class LottieControl extends React.Component { constructor(props) { super(props); this.state = {isStopped: false, isPaused: false}; } render() { const buttonStyle = { display: 'block', margin: '10px auto' }; const defaultOptions = { loop: true, autoplay: true, animationData: animationData, rendererSettings: { preserveAspectRatio: 'xMidYMid slice' } }; return <div> <Lottie options={defaultOptions} height={400} width={400} isStopped={this.state.isStopped} isPaused={this.state.isPaused}/> <button style={buttonStyle} onClick={() => this.setState({isStopped: true})}>stop</button> <button style={buttonStyle} onClick={() => this.setState({isStopped: false})}>play</button> <button style={buttonStyle} onClick={() => this.setState({isPaused: !this.state.isPaused})}>pause</button> </div> }}