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(iOS): reset to first frame on app resume bug #980

Merged
merged 3 commits into from Jan 31, 2023

Conversation

alfonsocj
Copy link
Contributor

@alfonsocj alfonsocj commented Jan 31, 2023

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
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

@alfonsocj alfonsocj marked this pull request as ready for review January 31, 2023 17:22
@alfonsocj
Copy link
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.

None yet

2 participants