@@ -58,8 +58,16 @@ angular.module('ui.bootstrap.modal', [])
58
58
* A helper directive for the $modal service. It creates a backdrop element.
59
59
*/
60
60
. directive ( 'modalBackdrop' , [
61
- '$animate' , '$modalStack' ,
62
- function ( $animate , $modalStack ) {
61
+ '$animate' , '$injector' , '$modalStack' ,
62
+ function ( $animate , $injector , $modalStack ) {
63
+ var $animateCss = null ;
64
+
65
+ if ( angular . version . minor >= 4 ) {
66
+ try {
67
+ $animateCss = $injector . get ( '$animateCss' ) ;
68
+ } catch ( e ) { }
69
+ }
70
+
63
71
return {
64
72
restrict : 'EA' ,
65
73
replace : true ,
@@ -72,19 +80,39 @@ angular.module('ui.bootstrap.modal', [])
72
80
73
81
function linkFn ( scope , element , attrs ) {
74
82
if ( attrs . modalInClass ) {
75
- $animate . addClass ( element , attrs . modalInClass ) ;
83
+ if ( $animateCss ) {
84
+ $animateCss ( element , {
85
+ addClass : attrs . modalInClass
86
+ } ) . start ( ) ;
87
+ } else {
88
+ $animate . addClass ( element , attrs . modalInClass ) ;
89
+ }
76
90
77
91
scope . $on ( $modalStack . NOW_CLOSING_EVENT , function ( e , setIsAsync ) {
78
92
var done = setIsAsync ( ) ;
79
- $animate . removeClass ( element , attrs . modalInClass ) . then ( done ) ;
93
+ if ( $animateCss ) {
94
+ $animateCss ( element , {
95
+ removeClass : attrs . modalInClass
96
+ } ) . start ( ) . then ( done ) ;
97
+ } else {
98
+ $animate . removeClass ( element , attrs . modalInClass ) . then ( done ) ;
99
+ }
80
100
} ) ;
81
101
}
82
102
}
83
103
} ] )
84
104
85
105
. directive ( 'modalWindow' , [
86
- '$modalStack' , '$q' , '$animate' ,
87
- function ( $modalStack , $q , $animate ) {
106
+ '$modalStack' , '$q' , '$animate' , '$injector' ,
107
+ function ( $modalStack , $q , $animate , $injector ) {
108
+ var $animateCss = null ;
109
+
110
+ if ( angular . version . minor >= 4 ) {
111
+ try {
112
+ $animateCss = $injector . get ( '$animateCss' ) ;
113
+ } catch ( e ) { }
114
+ }
115
+
88
116
return {
89
117
restrict : 'EA' ,
90
118
scope : {
@@ -125,11 +153,23 @@ angular.module('ui.bootstrap.modal', [])
125
153
126
154
modalRenderDeferObj . promise . then ( function ( ) {
127
155
if ( attrs . modalInClass ) {
128
- $animate . addClass ( element , attrs . modalInClass ) ;
156
+ if ( $animateCss ) {
157
+ $animateCss ( element , {
158
+ addClass : attrs . modalInClass
159
+ } ) . start ( ) ;
160
+ } else {
161
+ $animate . addClass ( element , attrs . modalInClass ) ;
162
+ }
129
163
130
164
scope . $on ( $modalStack . NOW_CLOSING_EVENT , function ( e , setIsAsync ) {
131
165
var done = setIsAsync ( ) ;
132
- $animate . removeClass ( element , attrs . modalInClass ) . then ( done ) ;
166
+ if ( $animateCss ) {
167
+ $animateCss ( element , {
168
+ removeClass : attrs . modalInClass
169
+ } ) . start ( ) . then ( done ) ;
170
+ } else {
171
+ $animate . removeClass ( element , attrs . modalInClass ) . then ( done ) ;
172
+ }
133
173
} ) ;
134
174
}
135
175
@@ -183,10 +223,19 @@ angular.module('ui.bootstrap.modal', [])
183
223
. factory ( '$modalStack' , [
184
224
'$animate' , '$timeout' , '$document' , '$compile' , '$rootScope' ,
185
225
'$q' ,
226
+ '$injector' ,
186
227
'$$stackedMap' ,
187
228
function ( $animate , $timeout , $document , $compile , $rootScope ,
188
229
$q ,
230
+ $injector ,
189
231
$$stackedMap ) {
232
+ var $animateCss = null ;
233
+
234
+ if ( angular . version . minor >= 4 ) {
235
+ try {
236
+ $animateCss = $injector . get ( '$animateCss' ) ;
237
+ } catch ( e ) { }
238
+ }
190
239
191
240
var OPENED_MODAL_CLASS = 'modal-open' ;
192
241
@@ -279,7 +328,15 @@ angular.module('ui.bootstrap.modal', [])
279
328
}
280
329
afterAnimating . done = true ;
281
330
282
- $animate . leave ( domEl ) ;
331
+ if ( $animateCss ) {
332
+ $animateCss ( domEl , {
333
+ event : 'leave'
334
+ } ) . start ( ) . then ( function ( ) {
335
+ domEl . remove ( ) ;
336
+ } ) ;
337
+ } else {
338
+ $animate . leave ( domEl ) ;
339
+ }
283
340
scope . $destroy ( ) ;
284
341
if ( done ) {
285
342
done ( ) ;
0 commit comments