Skip to content

Commit e0af215

Browse files
author
Lee Tunnicliffe
committed
ng-animate-ref leave clone element fix - Call $animate.leave on the cloned element rather than just remove to provide some more animation hooks.
1 parent a844138 commit e0af215

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

src/ngAnimate/animateCssDriver.js

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@ var $$AnimateCssDriverProvider = ['$$animationProvider', function($$animationPro
99
var NG_OUT_ANCHOR_CLASS_NAME = 'ng-anchor-out';
1010
var NG_IN_ANCHOR_CLASS_NAME = 'ng-anchor-in';
1111

12-
this.$get = ['$animateCss', '$rootScope', '$$AnimateRunner', '$rootElement', '$$body', '$sniffer', '$$jqLite',
13-
function($animateCss, $rootScope, $$AnimateRunner, $rootElement, $$body, $sniffer, $$jqLite) {
12+
this.$get = ['$animate', '$animateCss', '$rootScope', '$$AnimateRunner', '$rootElement', '$$body', '$sniffer', '$$jqLite',
13+
function($animate, $animateCss, $rootScope, $$AnimateRunner, $rootElement, $$body, $sniffer, $$jqLite) {
1414

1515
// only browsers that support these properties can render animations
1616
if (!$sniffer.animations && !$sniffer.transitions) return noop;
@@ -165,7 +165,7 @@ var $$AnimateCssDriverProvider = ['$$animationProvider', function($$animationPro
165165
}
166166

167167
function end() {
168-
clone.remove();
168+
$animate.leave(clone);
169169
outAnchor.removeClass(NG_ANIMATE_SHIM_CLASS_NAME);
170170
inAnchor.removeClass(NG_ANIMATE_SHIM_CLASS_NAME);
171171
}

test/ngAnimate/animateCssDriverSpec.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -888,8 +888,8 @@ describe("ngAnimate $$animateCssDriver", function() {
888888
expect(int(toStyles.left)).toBeGreaterThan(20);
889889
}));
890890

891-
it("should remove the cloned anchor node from the DOM once the 'in' animation is complete",
892-
inject(function($rootElement, $$rAF) {
891+
it("should remove the cloned anchor node from the DOM once the 'in' animation is complete using $animate leave to provide animation hooks",
892+
inject(function($rootElement, $$rAF, $animate, $rootScope) {
893893

894894
var fromAnchor = jqLite('<div class="blue green red"></div>');
895895
from.append(fromAnchor);
@@ -917,8 +917,11 @@ describe("ngAnimate $$animateCssDriver", function() {
917917

918918
// now the in animation completes
919919
expect(clonedAnchor.parent().length).toBe(1);
920+
921+
spyOn($animate, 'leave').andCallThrough();
920922
captureLog.pop().runner.end();
921923

924+
expect($animate.leave).toHaveBeenCalledWith(clonedAnchor);
922925
expect(clonedAnchor.parent().length).toBe(0);
923926
}));
924927

0 commit comments

Comments
 (0)