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

fix(ngAnimate): close follow-up class-based animations when the same class is added/removed when removed/added #11755

Closed
wants to merge 1 commit into from

Conversation

matsko
Copy link
Contributor

@matsko matsko commented Apr 29, 2015

This patch ensures that if the same CSS class is added/removed within a
follow-up digest then the previous class-based animation is cancelled
beforehand.

Closes #11717

…class is added/removed when removed/added

This patch ensures that if the same CSS class is added/removed within a
follow-up digest then the previous class-based animation is cancelled
beforehand.

Closes angular#11717
expect(closed).toBe(true);
}));

it('should cancel the previously running addClass animation if a follow-up removeClass animation is using the same class value',
Copy link
Member

Choose a reason for hiding this comment

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

aren't descriptions of those 2 tests swapped?

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you are right @mzgol.

var closed = false;
runner.done(function(status) {
closed = true;
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Is there a reason why you are not using spies for this kind of thing? I find it much more readable:

var doneHandler = jasmine.createSpy('addClass done');
runner.done(doneHandler);

$$rAF.flush();

expect(doneHandler).not.toHaveBeenCalled();

$animate.removeClass(element, 'active-class');
$rootScope.$digest();

expect(doneHandler).toHaveBeenCalled();

@petebacondarwin
Copy link
Contributor

Other than comments about descriptions and spies, this LGTM.

@petebacondarwin
Copy link
Contributor

I rebased this to merge but it causes another spec to fail at this line:

expect(capturedAnimation).toBeFalsy();

My suggested fix is to clear the animation state if a newly merged animation is invalid:

So this bit of code would look like:

      if (!isValidAnimation) {
        close();
        clearElementAnimationState(element);
        return runner;
      }

petebacondarwin added a commit to petebacondarwin/angular.js that referenced this pull request May 22, 2015
@petebacondarwin
Copy link
Contributor

Closing in favour of #11927

@matsko
Copy link
Contributor Author

matsko commented May 26, 2015

Landed as db246eb

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.

ngShow gives inconsistent results with ngAnimate
4 participants