Comments (10)
Echoing @xeroxoid. I get a reference error when I use the imperative API.
undefined is not an object (evaluating 'this.animation.start')
Turns out the Animation is not initialized when the componentDidMount is run so I used a timer. Definitely open to suggestions.
componentDidMount() {
this.initAnimation();
}
initAnimation(){
if (!this.animation){
setTimeout(() => {
this.initAnimation();
}, 100);
} else {
this.animation.play();
}
}
from lottie-react-native.
@agrosner is working but need to add a check (plz donβt ask me why ^^) :
<Animation
loop
source={source}
ref={animation => {
if (animation) animation.play()
}}
/>
"lottie-react-native": "^2.2.7"
from lottie-react-native.
<Animation
loop
source={source}
ref={(animation) => animation.play()}
/>
This seems to work even better
from lottie-react-native.
Thoughts on allowing loop to take a number as an option?
For cases where you want the animation to loop some amount of times less than infinity.
from lottie-react-native.
@eneskaya can you please post the whole snippet. I cant seem to figure out how you referenced initialized the animation.
from lottie-react-native.
Great idea.
from lottie-react-native.
Nice, works great π
from lottie-react-native.
@eneskaya do you know how I do a loop? I tried to add this loop
property but doesn't work
<Animation
source={ json }
progress={ this.state.progress }
loop={ true }
/>
from lottie-react-native.
@femontanha It only works with the imperative API, so be sure NOT to use progress
prop. Instead do something like this:
...
componentDidMount() {
this.animation.start();
}
render() {
<Animation
source={json}
style={{width: 100, height: 100}}
ref={(animation) => this.animation = animation} // the ref to the LottieAnimation component
loop
/>
}
from lottie-react-native.
@xeroxoid what do you mean, how I initialized the animation? (sorry for late reply)
from lottie-react-native.
Related Issues (20)
- Cannot build on latest RN 0.73.4 HOT 1
- Lottie 6.5.1: Source uri to local file not working on android. Error: sun.net.www.protocol.file.FileURLConnection cannot be cast to java.net.HttpURLConnection HOT 3
- Question. Frame Number? HOT 5
- iOS pod installation fails on Mackbook Pro M1 HOT 12
- Cannot convert undefined value to object (Error on Android only) HOT 3
- [Android] dotlottie files not working HOT 11
- pod install fail on MacOS 12.7.3(monterey) Xcode 14.2 HOT 3
- Lottie json crashes on Andriod devices but IOS works fine HOT 5
- RN 0.73.4 application keeps stopping HOT 3
- Download lotties json fies not working on expo android. HOT 4
- reduce motion: lottie files no longer animated HOT 1
- dotLottie will not load on web HOT 4
- Lottie animation is breaked on my app HOT 25
- Play method does not respect startFrame and endFrame properties
- Possible to change colorFilters dynamically without reseting animation? HOT 1
- [Android | Expo 50 | RN 0.73.4] Memory is not freed on unmount HOT 3
- How to remove lottie-react-native for windows HOT 1
- Cannot run IOS after installing lottie-react-native. HOT 1
- Lottie json crashes on Andriod devices but IOS works fine HOT 6
- Animation flickering & Some animations not even visible on Android HOT 5
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. πππ
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from lottie-react-native.