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

Expose completionBlock #330

Merged
merged 1 commit into from
Aug 2, 2017

Conversation

iwasrobbed-ks
Copy link
Contributor

Replaces #316

Background

PR #174 was a good first step towards enabling the chaining of animations, but it became apparent that the completionBlock should be decoupled from setting only via play() or else you'd end up with a very large nesting of animations.

Consider this a quick fix (only applicable for looping scenarios where you can explicitly control timing), but might be interesting to allow more explicit chaining or stitching together of animations in v2.0.

Example

Let's say you were creating a network spinner and needed a continuously rotating icon to eventually turn into a different icon after the network response returned success/failure.

Currently, you can create the looping animation and then when the network response returns, you set looping to false and it will call the completion block. This is fine, but if you also have many other animations, it soon becomes very messy and very nested since you are defining async code (e.g. the completion block) far away from its area of concerns.

If you could set the completion block on a given animation any time and then stop looping, it allows you to isolate the code better and keep your nesting to maybe one or two levels deep maximum.

@buba447
Copy link
Collaborator

buba447 commented Aug 2, 2017

This exposes the completion block but will not do what you intend. Currently I dont think that setting loopAnimation to false will do anything at all if the animation is already in progress.
Ill need to fix that!

@buba447 buba447 closed this Aug 2, 2017
@buba447 buba447 reopened this Aug 2, 2017
@buba447 buba447 merged commit 58443dc into airbnb:master Aug 2, 2017
@iwasrobbed-ks
Copy link
Contributor Author

Got it. In Lottie v1, setting loopAnimation to false will allow the animation to finish from its current progress and then call the completionBlock so I'll check if that behavior was maintained

@buba447
Copy link
Collaborator

buba447 commented Aug 3, 2017

@rob-keepsafe I looked into it and fixed the issue with this #332

@iwasrobbed-ks
Copy link
Contributor Author

@buba447 Thanks again!

@iwasrobbed-ks iwasrobbed-ks deleted the feature/completionSetter branch August 3, 2017 02:17
NSGolova pushed a commit to clario-tech/lottie-ios that referenced this pull request Nov 19, 2020
calda pushed a commit that referenced this pull request Dec 1, 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

Successfully merging this pull request may close these issues.

2 participants