1
- angular . module ( 'ui.bootstrap.modal' , [ 'ui.bootstrap.transition' ] )
1
+ angular . module ( 'ui.bootstrap.modal' , [ ] )
2
2
3
3
/**
4
4
* A helper, internal data structure that acts as a map but also allows getting / removing
@@ -131,8 +131,8 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition'])
131
131
} ;
132
132
} )
133
133
134
- . factory ( '$modalStack' , [ '$transition ' , '$timeout' , '$document' , '$compile' , '$rootScope' , '$$stackedMap' ,
135
- function ( $transition , $timeout , $document , $compile , $rootScope , $$stackedMap ) {
134
+ . factory ( '$modalStack' , [ '$animate ' , '$timeout' , '$document' , '$compile' , '$rootScope' , '$$stackedMap' ,
135
+ function ( $animate , $timeout , $document , $compile , $rootScope , $$stackedMap ) {
136
136
137
137
var OPENED_MODAL_CLASS = 'modal-open' ;
138
138
@@ -166,8 +166,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition'])
166
166
openedWindows . remove ( modalInstance ) ;
167
167
168
168
//remove window DOM element
169
- removeAfterAnimate ( modalWindow . modalDomEl , modalWindow . modalScope , 300 , function ( ) {
170
- modalWindow . modalScope . $destroy ( ) ;
169
+ removeAfterAnimate ( modalWindow . modalDomEl , modalWindow . modalScope , function ( ) {
171
170
body . toggleClass ( OPENED_MODAL_CLASS , openedWindows . length ( ) > 0 ) ;
172
171
checkRemoveBackdrop ( ) ;
173
172
} ) ;
@@ -177,28 +176,23 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition'])
177
176
//remove backdrop if no longer needed
178
177
if ( backdropDomEl && backdropIndex ( ) == - 1 ) {
179
178
var backdropScopeRef = backdropScope ;
180
- removeAfterAnimate ( backdropDomEl , backdropScope , 150 , function ( ) {
181
- backdropScopeRef . $destroy ( ) ;
179
+ removeAfterAnimate ( backdropDomEl , backdropScope , function ( ) {
182
180
backdropScopeRef = null ;
183
181
} ) ;
184
182
backdropDomEl = undefined ;
185
183
backdropScope = undefined ;
186
184
}
187
185
}
188
186
189
- function removeAfterAnimate ( domEl , scope , emulateTime , done ) {
187
+ function removeAfterAnimate ( domEl , scope , done ) {
190
188
// Closing animation
191
189
scope . animate = false ;
192
190
193
- var transitionEndEventName = $transition . transitionEndEventName ;
194
- if ( transitionEndEventName ) {
191
+ if ( $animate . enabled ( ) ) {
195
192
// transition out
196
- var timeout = $timeout ( afterAnimating , emulateTime ) ;
197
-
198
- domEl . bind ( transitionEndEventName , function ( ) {
199
- $timeout . cancel ( timeout ) ;
200
- afterAnimating ( ) ;
201
- scope . $apply ( ) ;
193
+ // TODO: use .one when upgrading to >= 1.2.21
194
+ domEl . on ( '$animate:close' , function closeFn ( ) {
195
+ $rootScope . $evalAsync ( afterAnimating ) ;
202
196
} ) ;
203
197
} else {
204
198
// Ensure this call is async
@@ -212,6 +206,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition'])
212
206
afterAnimating . done = true ;
213
207
214
208
domEl . remove ( ) ;
209
+ scope . $destroy ( ) ;
215
210
if ( done ) {
216
211
done ( ) ;
217
212
}
0 commit comments