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

Commit ca6b7d0

Browse files
committedJan 24, 2014
feat($animate): provide support for a close callback
Closes #5685 Closes #5053 Closes #4993
1 parent 40dc806 commit ca6b7d0

File tree

2 files changed

+18
-2
lines changed

2 files changed

+18
-2
lines changed
 

‎src/ngAnimate/animate.js

+4-1
Original file line numberDiff line numberDiff line change
@@ -828,7 +828,10 @@ angular.module('ngAnimate', ['ng'])
828828
}
829829

830830
function fireDoneCallbackAsync() {
831-
doneCallback && async(doneCallback);
831+
async(function() {
832+
fireDOMCallback('close');
833+
doneCallback && doneCallback();
834+
});
832835
}
833836

834837
//it is less complicated to use a flag than managing and cancelling

‎test/ngAnimate/animateSpec.js

+14-1
Original file line numberDiff line numberDiff line change
@@ -1519,7 +1519,13 @@ describe("ngAnimate", function() {
15191519
steps.push(['after', data.className, data.event]);
15201520
});
15211521

1522-
$animate.addClass(element, 'klass');
1522+
element.on('$animate:close', function(e, data) {
1523+
steps.push(['close', data.className, data.event]);
1524+
});
1525+
1526+
$animate.addClass(element, 'klass', function() {
1527+
steps.push(['done', 'klass', 'addClass']);
1528+
});
15231529

15241530
$timeout.flush(1);
15251531

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

15311537
expect(steps.pop()).toEqual(['after', 'klass', 'addClass']);
1538+
1539+
browserTrigger(element,'transitionend', { timeStamp: Date.now() + 1000, elapsedTime: 1 });
1540+
$timeout.flush(1);
1541+
1542+
expect(steps.shift()).toEqual(['close', 'klass', 'addClass']);
1543+
1544+
expect(steps.shift()).toEqual(['done', 'klass', 'addClass']);
15321545
}));
15331546

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

0 commit comments

Comments
 (0)