mirror of
https://github.com/Hopiu/angular.js.git
synced 2026-03-16 23:30:23 +00:00
feat($animate): provide support for a close callback
Closes #5685 Closes #5053 Closes #4993
This commit is contained in:
parent
40dc806e03
commit
ca6b7d0fa2
2 changed files with 18 additions and 2 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
|
||||
|
|
@ -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',
|
||||
|
|
|
|||
Loading…
Reference in a new issue