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
@@ -152,8 +152,8 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition'])
152
152
} ;
153
153
} )
154
154
155
- . factory ( '$modalStack' , [ '$transition ' , '$timeout' , '$document' , '$compile' , '$rootScope' , '$$stackedMap' ,
156
- function ( $transition , $timeout , $document , $compile , $rootScope , $$stackedMap ) {
155
+ . factory ( '$modalStack' , [ '$animate ' , '$timeout' , '$document' , '$compile' , '$rootScope' , '$$stackedMap' ,
156
+ function ( $animate , $timeout , $document , $compile , $rootScope , $$stackedMap ) {
157
157
158
158
var OPENED_MODAL_CLASS = 'modal-open' ;
159
159
@@ -187,8 +187,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition'])
187
187
openedWindows . remove ( modalInstance ) ;
188
188
189
189
//remove window DOM element
190
- removeAfterAnimate ( modalWindow . modalDomEl , modalWindow . modalScope , 300 , function ( ) {
191
- modalWindow . modalScope . $destroy ( ) ;
190
+ removeAfterAnimate ( modalWindow . modalDomEl , modalWindow . modalScope , function ( ) {
192
191
body . toggleClass ( OPENED_MODAL_CLASS , openedWindows . length ( ) > 0 ) ;
193
192
checkRemoveBackdrop ( ) ;
194
193
} ) ;
@@ -198,28 +197,23 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition'])
198
197
//remove backdrop if no longer needed
199
198
if ( backdropDomEl && backdropIndex ( ) == - 1 ) {
200
199
var backdropScopeRef = backdropScope ;
201
- removeAfterAnimate ( backdropDomEl , backdropScope , 150 , function ( ) {
202
- backdropScopeRef . $destroy ( ) ;
200
+ removeAfterAnimate ( backdropDomEl , backdropScope , function ( ) {
203
201
backdropScopeRef = null ;
204
202
} ) ;
205
203
backdropDomEl = undefined ;
206
204
backdropScope = undefined ;
207
205
}
208
206
}
209
207
210
- function removeAfterAnimate ( domEl , scope , emulateTime , done ) {
208
+ function removeAfterAnimate ( domEl , scope , done ) {
211
209
// Closing animation
212
210
scope . animate = false ;
213
211
214
- var transitionEndEventName = $transition . transitionEndEventName ;
215
- if ( transitionEndEventName ) {
212
+ if ( $animate . enabled ( ) ) {
216
213
// transition out
217
- var timeout = $timeout ( afterAnimating , emulateTime ) ;
218
-
219
- domEl . bind ( transitionEndEventName , function ( ) {
220
- $timeout . cancel ( timeout ) ;
221
- afterAnimating ( ) ;
222
- scope . $apply ( ) ;
214
+ // TODO: use .one when upgrading to >= 1.2.21
215
+ domEl . on ( '$animate:close' , function closeFn ( ) {
216
+ $rootScope . $evalAsync ( afterAnimating ) ;
223
217
} ) ;
224
218
} else {
225
219
// Ensure this call is async
@@ -233,6 +227,7 @@ angular.module('ui.bootstrap.modal', ['ui.bootstrap.transition'])
233
227
afterAnimating . done = true ;
234
228
235
229
domEl . remove ( ) ;
230
+ scope . $destroy ( ) ;
236
231
if ( done ) {
237
232
done ( ) ;
238
233
}
0 commit comments