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

Commit df1a00b

Browse files
matskoIgorMinar
authored andcommitted
fix($animate): permit class-based animations for leave operations if ngAnimateChildren is enabled
Prior to this fix, $animate.leave placed a disabled animation on the element which prevented ngAnimateChildren from properly working. This patch now addresses that issue. Closes #8092 Closes #9491
1 parent d9ff4e4 commit df1a00b

File tree

2 files changed

+56
-1
lines changed

2 files changed

+56
-1
lines changed

src/ngAnimate/animate.js

-1
Original file line numberDiff line numberDiff line change
@@ -831,7 +831,6 @@ angular.module('ngAnimate', ['ng'])
831831

832832
cancelChildAnimations(element);
833833
classBasedAnimationsBlocked(element, true);
834-
this.enabled(false, element);
835834
return runAnimationPostDigest(function(done) {
836835
return performAnimation('leave', 'ng-leave', stripCommentsFromElement(element), null, null, function() {
837836
$delegate.leave(element);

test/ngAnimate/animateSpec.js

+56
Original file line numberDiff line numberDiff line change
@@ -4826,6 +4826,62 @@ describe("ngAnimate", function() {
48264826
expect(spy).toHaveBeenCalled();
48274827
expect(spy.callCount).toBe(1);
48284828
}));
4829+
4830+
it('should permit class-based animations when ng-animate-children is true for a structural animation', function() {
4831+
var spy = jasmine.createSpy();
4832+
4833+
module(function($animateProvider) {
4834+
$animateProvider.register('.inner', function() {
4835+
return {
4836+
beforeAddClass : function(element, className, done) {
4837+
spy();
4838+
done();
4839+
},
4840+
beforeRemoveClass : function(element, className, done) {
4841+
spy();
4842+
done();
4843+
}
4844+
};
4845+
});
4846+
});
4847+
4848+
inject(function($animate, $sniffer, $rootScope, $compile) {
4849+
4850+
$animate.enabled(true);
4851+
4852+
var html = '<div ng-animate-children>' +
4853+
' <div class="inner" ng-class="{animate:bool}">...</div>' +
4854+
'</div>';
4855+
4856+
var element = angular.element(html);
4857+
$compile(element)($rootScope);
4858+
var body = angular.element($document[0].body);
4859+
body.append($rootElement);
4860+
4861+
$rootScope.$watch('bool', function(bool) {
4862+
if (bool) {
4863+
$animate.enter(element, $rootElement);
4864+
} else if(element.parent().length) {
4865+
$animate.leave(element);
4866+
}
4867+
});
4868+
4869+
$rootScope.$digest();
4870+
expect(spy.callCount).toBe(0);
4871+
4872+
$rootScope.bool = true;
4873+
$rootScope.$digest();
4874+
$animate.triggerReflow();
4875+
$animate.triggerCallbacks();
4876+
expect(spy.callCount).toBe(1);
4877+
4878+
$rootScope.bool = false;
4879+
$rootScope.$digest();
4880+
$animate.triggerReflow();
4881+
$animate.triggerCallbacks();
4882+
expect(spy.callCount).toBe(2);
4883+
});
4884+
});
48294885
});
48304886

48314887
describe('SVG', function() {

0 commit comments

Comments
 (0)