Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This fixes #970. That issue was not actually resolved.
And also fixes #975
Before this change, calling stop() on an AnimationView that is playing did not work properly. It would not return to the first frame of the animation. And when it did, it would "reverse" the animation.
The reversing is because this PR put CATransaction.setCompletionBlock outside the CATransaction begin/commit block. CATransaction.setCompletionBlock needs to occur between CATransaction.begin and CATransaction.commit.
This PR moves that setCompletionBlock to the correct place.
After moving that code block, the animation would still not return to frame 0 when stop is called, but when a subsequent animation is play()'d, the animation would return to frame 0 without reversing.
It seemed clear to me, based on this behaviour, that some of the CATransaction stuff or the setNeedsDisplay() system is not working properly.
To remedy this, I have put a flush() in stop().
This fixes the problem. But I realize that the flush shouldnt need to be there. There are some deeper bugs in lottie-ios, but at least this fixes the symptom.
Tagging @buba447 @dcramps @ferico55 @thedrick