Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Only One Circle Appears in the Animation Instead of Two #2407

Open
brstorm-jonghyunlee opened this issue May 16, 2024 · 2 comments
Open

Only One Circle Appears in the Animation Instead of Two #2407

brstorm-jonghyunlee opened this issue May 16, 2024 · 2 comments

Comments

@brstorm-jonghyunlee
Copy link

Which Version of Lottie are you using?

Lottie 4.4.3

Expected Behavior

2024-05-16.5.02.25.mov

Actual Behavior

2024-05-16.4.59.57.mov

Animation JSON

Lottie Animation Link
doubleSpinner.json

Code

Since our main app is based on SwiftUI, we are using a wrapper around LottieAnimationView. However, we have also tried using the SwiftUI version of LottieView, and we have attempted the solutions suggested in other issues, including changing the RenderingEngine. Unfortunately, the problem persists.

Thank you for always providing such a great library.


import Lottie
import SwiftUI

struct CustomLottieView: UIViewRepresentable {
var animationFileName: String
let loopMode: LottieLoopMode

func updateUIView(_ uiView: UIView, context: Context) {}

func makeUIView(context: Context) -> UIView {
    let view = UIView(frame: .zero)

    let configuration = LottieConfiguration(renderingEngine: .mainThread)
    let animationView = LottieAnimationView(name: animationFileName, configuration: configuration)

    animationView.loopMode = loopMode
    animationView.contentMode = .scaleAspectFill
    animationView.translatesAutoresizingMaskIntoConstraints = false

    view.addSubview(animationView)

    NSLayoutConstraint.activate([
        animationView.widthAnchor.constraint(equalTo: view.widthAnchor),
        animationView.heightAnchor.constraint(equalTo: view.heightAnchor),
        animationView.centerXAnchor.constraint(equalTo: view.centerXAnchor),
        animationView.centerYAnchor.constraint(equalTo: view.centerYAnchor)
    ])

    animationView.play()

    return view
}

}

#if DEBUG
#Preview {
CustomLottieView(animationFileName: "doubleSpinner",
loopMode: .loop)
.frame(width: 200, height: 200)
}
#endif

@brstorm-jonghyunlee
Copy link
Author

Additionally, the same issue occurs with .lottie file formats.

@monkeyRing
Copy link

Your Lottie JSON animation file has a problem; it’s not an issue with the Lottie SDK.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants