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

Commit

Permalink
feat($animate): provide support for a close callback
Browse files Browse the repository at this point in the history
Closes #5685
Closes #5053
Closes #4993
  • Loading branch information
matsko committed Jan 24, 2014
1 parent 40dc806 commit ca6b7d0
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 2 deletions.
5 changes: 4 additions & 1 deletion src/ngAnimate/animate.js
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,10 @@ angular.module('ngAnimate', ['ng'])
}

function fireDoneCallbackAsync() {
doneCallback && async(doneCallback);
async(function() {
fireDOMCallback('close');
doneCallback && doneCallback();
});
}

//it is less complicated to use a flag than managing and cancelling
Expand Down
15 changes: 14 additions & 1 deletion test/ngAnimate/animateSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -1519,7 +1519,13 @@ describe("ngAnimate", function() {
steps.push(['after', data.className, data.event]);
});

$animate.addClass(element, 'klass');
element.on('$animate:close', function(e, data) {
steps.push(['close', data.className, data.event]);
});

$animate.addClass(element, 'klass', function() {
steps.push(['done', 'klass', 'addClass']);
});

$timeout.flush(1);

Expand All @@ -1529,6 +1535,13 @@ describe("ngAnimate", function() {
$timeout.flush(1);

expect(steps.pop()).toEqual(['after', 'klass', 'addClass']);

browserTrigger(element,'transitionend', { timeStamp: Date.now() + 1000, elapsedTime: 1 });
$timeout.flush(1);

expect(steps.shift()).toEqual(['close', 'klass', 'addClass']);

expect(steps.shift()).toEqual(['done', 'klass', 'addClass']);
}));

it('should fire the DOM callbacks even if no animation is rendered',
Expand Down

0 comments on commit ca6b7d0

Please sign in to comment.