Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Synchronous Classes in ngAnimate #12248

Closed
wants to merge 4 commits into from

Conversation

matsko
Copy link
Contributor

@matsko matsko commented Jun 30, 2015

This PR ensures that classes added via $animate are always applied after the first digest instead of after the first requestAnimationFrame.

Closes #11975
Closes #12276

@IgorMinar
Copy link
Contributor

reviewed with Matsko. once all tests and demos are passing then this LGTM

@matsko
Copy link
Contributor Author

matsko commented Jul 17, 2015

@petebacondarwin could you please review?

@matsko matsko force-pushed the ng_animate_sync_classes branch from b16d747 to d50894d Compare July 20, 2015 20:40
…losed by their children

This fix ensures that a structural child animation will never close a
parent class based early so that the CSS classes for the child are ready
for it to perform its CSS animation. The reasoning for the past for this
was because their is a one frame delay before the classes were applied.
If a parent and a child animation happen at the same time then the
animations may not be picked up for the element since the CSS classes
may not have been applied yet.

This fix ensures that parent CSS classes are applied in a synchronous
manner without the need to run a one RAF wait. The solution to this was
to apply the preparation classes during the pre-digest phase and then
apply the CSS classes right after with a forced reflow paint.

BREAKING CHANGE: CSS classes added/removed by ngAnimate are now applied
synchronously once the first digest has passed.

The previous behavior involved ngAnimate having to wait for one
requestAnimationFrame before CSS classes were added/removed. The CSS classes
are now applied directly after the first digest that is triggered after
`$animate.addClass`, `$animate.removeClass` or `$animate.setClass` is
called. If any of your code relies on waiting for one frame before
checking for CSS classes on the element then please change this
behavior. If a parent class-based animation, however, is run through a
JavaScript animation which triggers an animation for `beforeAddClass`
and/or `beforeRemoveClass` then the CSS classes will not be applied
in time for the children (and the parent class-based animation will not
be cancelled by any child animations).

Closes angular#11975
Closes angular#12276
@matsko
Copy link
Contributor Author

matsko commented Jul 20, 2015

Landed as 32d3cbb

@matsko matsko closed this Jul 20, 2015
@matsko matsko deleted the ng_animate_sync_classes branch July 20, 2015 21:23
@petebacondarwin
Copy link
Contributor

Great!

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants