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

Fix issue where play(fromProgress: 1, toProgress: 0) animation would not actually play #1908

Merged
merged 2 commits into from
Jan 9, 2023

Conversation

calda
Copy link
Member

@calda calda commented Jan 9, 2023

This PR fixes an issue where animations would be ignored when toFrame == currentFrame. For example, when playing from 100% to 0% when the animation view is created (and currentFrame == 0), the animation was previously ignored. Fixes #1901 and #1907.

Before After

case .playOnce:
animationContext.playFrom = currentFrame
if animationContext.playTo != currentFrame {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is basically the same logic that the Main Thread rendering engine has here: https://github.com/airbnb/lottie-ios/blob/master/Sources/Public/Animation/LottieAnimationView.swift#L1422

@@ -65,6 +65,7 @@ final class AnimationViewTests: XCTestCase {
let tests: [(fromFrame: AnimationFrameTime?, toFrame: AnimationFrameTime)] = [
(fromFrame: nil, toFrame: 10),
(fromFrame: 8, toFrame: 14),
(fromFrame: 14, toFrame: 0),
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a test case for this, which fails on master

Co-authored-by: Eric Horacek <eric.horacek@airbnb.com>
@calda calda enabled auto-merge (squash) January 9, 2023 21:06
@calda calda disabled auto-merge January 9, 2023 21:09
@calda calda enabled auto-merge (squash) January 9, 2023 21:09
@calda calda merged commit 79ae25e into master Jan 9, 2023
@calda calda deleted the cal--play-animation-backwards branch January 9, 2023 21:52
iago849 pushed a commit to atteamapps/lottie-ios that referenced this pull request Feb 8, 2024
MoroziOS pushed a commit to MoroziOS/tmg-lottie-ios that referenced this pull request May 22, 2024
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.

Minor AnimatedSwitch behavior difference between the Core Animation Engine and the Main Thread Engine
2 participants