-
Notifications
You must be signed in to change notification settings - Fork 27.4k
fix($animateCss): avoid flicker caused by temporary classes #15472
fix($animateCss): avoid flicker caused by temporary classes #15472
Conversation
Currently, this only affects `ngHide`/`ngShow` animations (but the problem was more general and could theoretically affect other animations in the future). Adding the temporary classes immediately, while forcing a reflow before starting the animation, could cause flickering. This commit fixes the issue, by not applying the temporary classes until the animation actually starts. Since `tempClasses` was an undocumented, private feature (currently only used for `ngHide`/`ngShow`), no other built-in or custom animations will be affected. Alternative approach to angular#15463. Fixes angular#14015 Closes angular#15463
I think that's good. Just to clarify, before this change was it possible to use a temporary class to trigger a css animation? I.e. a temporary class applies a transition that makes the animator detect an animation. |
It was and it still is. This PR only affects adding the classes in |
Actually, the current ngHide example from the docs doesn't work correctly for the "show" (ng-hide-remove) action with this patch, see https://plnkr.co/edit/tyteqvfPbhcwrBKXpn5c?p=preview When you comment in the patched angular-animate (copied from you pen), the show action doesn't animate anymore. |
😞 It's always possible that I've missed something. If #15463 works, I'm happy to go with that. |
My PR actually has the same problem ... the thing is that the plnkr example I posted puts the actual transition css on the temporary class, which is not something we advocate. I'm not sure where I got this plnkr / css from, maybe an issue or something? Though the |
The question is: Can we fix the issue without breaking the usecase? |
I don't think so. The rAF call that causes this is elementary to the way ngAnimate works. Removing it or working around it would probably mean a big rewrite. |
In that case, I vote for fixing it with a breaking change (i.e. that animation styles on temporary classes won't work) for 1.7.0. |
Bad news: I've re-tested the plnkr with our patches, and even with the regular ngShow / ngHide example from the docs, they don't work for showing: https://plnkr.co/edit/tyteqvfPbhcwrBKXpn5c?p=preview (the current ngAnimate file is active, but use the patched files and it doesn't work). |
Here's the original repro to test again: https://plnkr.co/edit/l70kaJ?p=preview (flickers in IE11reliably) |
Yeah, I realized our both our fixes are problematic. I started looking into the issue again 😞 |
I give up 😱 Unfortunately, I couldn't get to the bottom of this in a reasonable amount of time 😞
In any case, I am going to close this PR, because it breaks a valid usecase, so is not an appropriate fix anyway. |
What kind of change does this PR introduce? (Bug fix, feature, docs update, ...)
Bug fix.
What is the current behavior? (You can also link to an open issue here)
Adding the temporary classes immediately, while forcing a reflow before starting the animation, could cause flickering. Currently, only
ngHide
/ngShow
animations are affected (but theoretically any future animation relying ontempClasses
would be).See #14015.
What is the new behavior (if this is a feature change)?
The temporary classes are not applied until the animation actually starts, which avoids the flickering.
Does this PR introduce a breaking change?
No. (Since
tempClasses
was an undocumented, private feature (currently only used forngHide
/ngShow
), no other built-in or custom animations will be affected).Please check if the PR fulfills these requirements
Docs have been added / updated (for bug fixes / features)Other information:
This is an alternative approach to #15463.
Fixes #14015.