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

fix(ngAnimate): properly cancel-out previously running class-based an… #13822

Closed
wants to merge 1 commit into from

Conversation

Narretz
Copy link
Contributor

@Narretz Narretz commented Jan 22, 2016

…imations

Prior to this fix the addition and removal of a CSS class via
ngAnimate would cause flicker effects because $animate was unable
to keep track of the CSS classes once they were applied to the
element. This fix ensures that ngAnimate always keeps a reference
to the classes in the currently running animation so that cancelling
works accordingly.

Closes #10156
Closes #13814

This updated PR adds a new test that ensures the buggy scenario is correctly reproduced. We need to actively start the animation by flushing a requestAnimationFrame, otherwise the addClass / removeClass values are not correct.

@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.

1 similar comment
@googlebot
Copy link

We found a Contributor License Agreement for you (the sender of this pull request) and all commit authors, but as best as we can tell these commits were authored by someone else. If that's the case, please add them to this pull request and have them confirm that they're okay with these commits being contributed to Google. If we're mistaken and you did author these commits, just reply here to confirm.

@@ -374,11 +373,10 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
close();
return runner;
} else {
mergeAnimationOptions(element, existingAnimation.options, options);
mergeAnimationDetails(element, existingAnimation.options, options);
Copy link
Member

Choose a reason for hiding this comment

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

How come we don't need to pass the animation object, but the options (considering all other invocation changed) ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Gooood question. Or, better question: why is there no failing test ....

@@ -25,6 +25,32 @@ describe('ngAnimate integration tests', function() {
ss.destroy();
});

it('should cancel a running and started removeClass animation when a follow-up addClass animation adds the same class',
Copy link
Member

Choose a reason for hiding this comment

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

what does it mean to be "running and started"?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, another very good question. Internally, there's a running state, but that can mean two things: first, the animation process waits for the next digest to happen; then it flushes an requestAnimationFrame (for the reflow) to trigger the actual animation start. The previous test didn'T flush the rAF, and so the scenario wasn't created.

Narretz pushed a commit to Narretz/angular.js that referenced this pull request Jan 22, 2016
…imations

Prior to this fix the addition and removal of a CSS class via
ngAnimate would cause flicker effects because $animate was unable
to keep track of the CSS classes once they were applied to the
element. This fix ensures that ngAnimate always keeps a reference
to the classes in the currently running animation so that cancelling
works accordingly.

The commit also adds a test for a previously untested animation merge path.

Closes angular#10156
Closes angular#13822
@Narretz
Copy link
Contributor Author

Narretz commented Jan 22, 2016

@gkalpak I've updated the merge code and added a test for this path. PTAL.

@gkalpak
Copy link
Member

gkalpak commented Jan 22, 2016

LGTM

…imations

Prior to this fix the addition and removal of a CSS class via
ngAnimate would cause flicker effects because $animate was unable
to keep track of the CSS classes once they were applied to the
element. This fix ensures that ngAnimate always keeps a reference
to the classes in the currently running animation so that cancelling
works accordingly.

The commit also adds a test for a previously untested animation merge path.

Closes angular#10156
Closes angular#13822
@Narretz Narretz closed this in 20b8ece Jan 23, 2016
Narretz pushed a commit that referenced this pull request Jan 23, 2016
…imations

Prior to this fix the addition and removal of a CSS class via
ngAnimate would cause flicker effects because $animate was unable
to keep track of the CSS classes once they were applied to the
element. This fix ensures that ngAnimate always keeps a reference
to the classes in the currently running animation so that cancelling
works accordingly.

The commit also adds a test for a previously untested animation merge path.

Closes #10156
Closes #13822
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.

Flickering with ngAnimate and ngShow
5 participants