Thanks to visit codestin.com
Credit goes to github.com

Skip to content

fix(iOS): reset to first frame on app resume bug#980

Merged
matinzd merged 3 commits into
lottie-react-native:masterfrom
alfonsocj:alfonso/resume-bug
Jan 31, 2023
Merged

fix(iOS): reset to first frame on app resume bug#980
matinzd merged 3 commits into
lottie-react-native:masterfrom
alfonsocj:alfonso/resume-bug

Conversation

@alfonsocj

@alfonsocj alfonsocj commented Jan 31, 2023

Copy link
Copy Markdown
Contributor

This fixes the bug where the animation resets to its first frame when going to background and resume.
Issue: #825

Why this problem occured?

When going to background, traitCollectionDidChange method runs which calls applyProperties(). This changes the animation's current progress animationView.currentProgress = progress and progress comes from props. If not defined it defaults to 0 (first frame).

Additionally, setting backgroundBehavior = .pauseAndRestore has a weird behavior. When the animation ends and the app goes to background, it sets the animation to the first frame. Forcing the currentProgress to the last frame when the animation ends works fine to mitigate the issue.

Before

Screen.Recording.2023-01-31.at.10.30.04.AM.mov

After

Jan-31-2023.12-10-05-2.mov


func applyProperties() {
func applyColorProperties() {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Only apply color properties here. Setting animationSpeed or loopMode resets the animation

Comment thread packages/core/ios/LottieReactNative/ContainerView.swift
@alfonsocj alfonsocj marked this pull request as ready for review January 31, 2023 17:22
@alfonsocj

Copy link
Copy Markdown
Contributor Author

@matinzd I think it's ready for review.

@matinzd matinzd changed the title Fix reset to first frame on app resume bug fix(iOS): reset to first frame on app resume bug Jan 31, 2023
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