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

Leave Animation callback overridden by next animation #12271

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/ngAnimate/animateQueue.js
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,7 @@ var $$AnimateQueueProvider = ['$animateProvider', function($animateProvider) {
push: function(element, event, options, domOperation) {
options = options || {};
options.domOperation = domOperation;
options.hasDomOpreation = !isUndefined(domOperation);
return queueAnimation(element, event, options);
},

Expand Down
7 changes: 7 additions & 0 deletions src/ngAnimate/shared.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,9 +171,16 @@ function mergeAnimationOptions(element, target, newOptions) {
var toAdd = (target.addClass || '') + ' ' + (newOptions.addClass || '');
var toRemove = (target.removeClass || '') + ' ' + (newOptions.removeClass || '');
var classes = resolveElementClasses(element.attr('class'), toAdd, toRemove);
var targetDomOperation = target.hasDomOpreation ? target.domOperation : null;

extend(target, newOptions);

// TODO : proper fix is to maintain all animation callback in array and call at last,but now only leave has the callback so no issue with this.
if (targetDomOperation) {
target.hasDomOpreation = true;
target.domOperation = targetDomOperation;
}

if (classes.addClass) {
target.addClass = classes.addClass;
} else {
Expand Down
19 changes: 19 additions & 0 deletions test/ngAnimate/animateSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1646,5 +1646,24 @@ describe("animations", function() {
expect(count).toBe(1);
}));

it('Leave : should remove the element even other animation are called after leave, should not override leave callback',
inject(function($animate, $rootScope, $$rAF, $rootElement) {

var isElementRemoved = false;
var outerContainer = jqLite('<div></div>');
element = jqLite('<div></div>');
outerContainer.append(element);
$rootElement.append(outerContainer);
var runner = $animate.leave(element, $rootElement);
$animate.removeClass(element,'rclass');
$rootScope.$digest();
runner.end();
$$rAF.flush();

isElementRemoved = !outerContainer[0].contains(element[0]);

expect(isElementRemoved).toBe(true);
}));

});
});