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

Changing animations mid way does not work #1545

Closed
mnive93 opened this issue Apr 14, 2022 · 1 comment
Closed

Changing animations mid way does not work #1545

mnive93 opened this issue Apr 14, 2022 · 1 comment

Comments

@mnive93
Copy link

mnive93 commented Apr 14, 2022

Lottie-iOS Issue

I have an animation that is running in .loop mode. When the api call fetch is done , I want to update the animation mid way to a success / failure animation. Setting the animationView to a new animation and then playing does not play anything. The view is empty and it is not loading any animation

Check these before submitting:

  • []
  • []

This issue is a:

  • [] Non-Crashing Bug (Visual or otherwise)

Which Version of Lottie are you using?

Lottie 3.2.3

What Platform are you on?

  • [] iOS

What Language are you in?

  • [] Swift

Code Example

      self.animationView.play { isfinished in
        let path = BundleLocator.getResourcesBundle()?.path(forResource: "lottie_animation", ofType: "json") ?? ""
        
        let animation = Animation.filepath(path)
        
        self.animationView.loopMode = .loop
        self.animationView.animation = animation
        self.animationView.play()
    }

Animation JSON

The animation json plays normally when I load it first. Loading it after the first one fails

@mnive93
Copy link
Author

mnive93 commented Apr 17, 2022

Found a way around for this. Have to actually remove the view from its parent superview and re-add it again for this to work.
However doing this way is causing a flicker in the animation when I am trying to remove and add it again. Kindly help

 
         self.animationView.removeFromSuperview()
        let animation = Animation.filepath(path)       
        self.animationView.animation = animation
        self.animationView.loopMode = .playOnce
        animationView.frame = uiView.bounds
        animationView.contentMode = .scaleAspectFit

        uiView.addSubview(animationView)

@mnive93 mnive93 closed this as completed Apr 19, 2022
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

1 participant