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 background glitch #15

Merged
merged 3 commits into from Jul 14, 2015
Merged

Conversation

andreamazz
Copy link
Contributor

This should fix #14 although it might need to be documented in the readme since this happens also when you have a fluid view in a tab. Once the user switches tabs and goes back to the one with the fluid we should stop and restart the animation as well. In this case the UIApplicationWillResignActiveNotification and UIApplicationDidBecomeActiveNotification won't do the trick and we need to use for instance viewWillAppear/Disappear.

What do you think?

@antiguab
Copy link
Owner

Hey! Thanks for all the help. We should definitely use UIApplicationWillResignActiveNotification and UIApplicationDidBecomeActiveNotification. Any reason you put it in BAViewController and not the BAFluidView (since the methods only affect UI elements)? Instead of using viewWillAppear in the viewController, I used willMoveToWindow in the BAFluidView. Figured this way we can avoid having the developer deal with it. Let me know what you think! branch w/ proposed fix

@andreamazz
Copy link
Contributor Author

I exposed that because the same issue happens if you have a tab controller. Let's say that tab 1 has a fluid view, when the users switches to tab 2 and back to tab 1 you'll find the wave animation glitched. That can be fixed by starting and stopping the animation in viewWillAppear: and viewWillDisappear:, catching UIApplicationWillResignActiveNotification won't work.

@antiguab
Copy link
Owner

Right! So my solution (instead of viewWillAppear:) was to do this in BAFluidView:

- (void)willMoveToWindow:(UIWindow *)newWindow {
    if(newWindow == nil){
        //the view is being removed
        [self stopAnimation];
        return;
    }

    //the view is being added
    [self startAnimation];
}

Which results in this:
tabfix

Thoughts?

@andreamazz
Copy link
Contributor Author

Brilliant!

@andreamazz
Copy link
Contributor Author

Ok, tested it on Gulps and it works great. The API is also cleaner, the startAnimation call is no longer required 👍

antiguab added a commit that referenced this pull request Jul 14, 2015
@antiguab antiguab merged commit 23c7f86 into antiguab:master Jul 14, 2015
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.

Animation glitched after entering background
2 participants