Comments (1)
The problem here is that:
- Loading a dotLottie animation with images applies a
DotLottieImageProvider
to theLottieAnimationView
- Switching to a json animation doesn't clear the
DotLottieImageProvider
DotLottieImageProvider
s don't handle base 64 images, and instead return nil.
A simple fix on our side is to just update DotLottieImageProvider
to handle base 64 image providers. We'll make this change and it will be included in the next release.
In the meantime, a workaround on your side could be to switch back to using the standard BundleImageProvider
after switching from a dotLottie animation to a standard JSON animation. Updating your loadAnimation
method to the following fixes the issue:
private func loadAnimation(url: URL) {
if url.pathExtension == "json" {
LottieAnimation.loadedFrom(url: url) { [weak self] animation in
guard let self else { return }
if let animation {
self.animationView?.animation = animation
self.animationView?.loopMode = .loop
animationView.imageProvider = BundleImageProvider(bundle: Bundle.main, searchPath: nil)
animationView.play()
label.text = "Animation shown: URL JSON"
}
}
} else {
DotLottieFile.loadedFrom(url: url) { [weak self] result in
guard let self else { return }
if case .success(let dotLottie) = result {
self.animationView?.loadAnimation(from: dotLottie)
self.animationView?.animationLoaded = { [weak self] animationView, _ in
animationView.loopMode = .loop
animationView.play()
self?.label.text = "Animation shown: URL DotLottie"
}
}
}
}
}
The SwiftUI LottieView
doesn't have this issue, because we switch back to the user-provided AnimationImageProvider
after switching away from a dotLottie animation.
from lottie-ios.
Related Issues (20)
- reuse LottieView and prevent .configure from being called again HOT 2
- no rule to process file 'PrivacyInfo.xcprivacy' of type 'text.xml' with CocoaPods HOT 8
- I am seeing 'Command PhaseScriptExecution failed HOT 2
- Modifying state during view update, this will cause undefined behavior.
- `PrivacyInfo.xcprivacy` is not included in `lottie-spm` repo HOT 4
- Warning in Xcode when using Lottie 4.4.0 with cocoa pods HOT 1
- LottieAnimationView layout stuck in infinite loop HOT 5
- Completion Closure Not Called in CA Mode Like in Main Thread Mode HOT 1
- LottieView.animationDidFinish not called correctly when background behavior is set to continue playing
- Lottie missing elements in Animation HOT 3
- SPM fails to compile when lottie-spm is added via SPM Package.swift file HOT 1
- module map 'xxx/lottie-ios/Lottie.modulemap' not found HOT 2
- can't clone Lottie iOS on cocoa pods HOT 2
- lottie-spm fails builds in GitHub Actions
- Lottie animation freezes whole app on 4.4.0/4.4.1 (works fine on 4.3.1) HOT 1
- Lottie animation freezes whole app on 4.4.0/4.4.1 (works fine on 4.3.1) HOT 1
- Password with a space is being used while joining the network using airbnb app
- Troubleshooting Lottie Integration Errors in GitHub Actions CI/CD Pipeline HOT 2
- The signature of “Lottie.xcframework” cannot be validated and may have been compromised. HOT 4
- SPM: skipping cache due to an error HOT 1
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-ios.