Skip to content
This repository has been archived by the owner on May 29, 2019. It is now read-only.

fix(modal): Modal Dialog doesn't fade out #3888

Closed
wants to merge 1 commit into from
Closed
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
24 changes: 20 additions & 4 deletions src/modal/modal.js
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,21 @@ angular.module('ui.bootstrap.modal', [])
scope.animate = false;

if (domEl.attr('modal-animation') && $animate.enabled()) {
// transition out
domEl.one('$animate:close', function closeFn() {
$rootScope.$evalAsync(afterAnimating);
});
// transition out, angular 1.4 or <1.4?
if ($animate.on) {
// angular 1.4. use $animiate.on to capture a removeClass event in the "close" phase to detect the
// completion of the animation.
$animate.on('removeClass', domEl, function closeFn(element, phase) {
if (phase === 'close') {
$rootScope.$evalAsync(afterAnimating);
}
});
} else {
// angular <1.4 pickup the "close" event from the element to detect the completion of the animation.
domEl.one('$animate:close', function closeFn() {
$rootScope.$evalAsync(afterAnimating);
});
}
} else {
// Ensure this call is async
$timeout(afterAnimating);
Expand All @@ -249,6 +260,11 @@ angular.module('ui.bootstrap.modal', [])
}
afterAnimating.done = true;

// angular 1.4 doesn't have a oneOff function, so we have to remove the event listener manually.
if ($animate.off) {
$animate.off('removeClass', domEl);
}

domEl.remove();
scope.$destroy();
if (done) {
Expand Down