@@ -122,7 +122,8 @@ var $AnimateProvider = ['$provide', function($provide) {
122
122
}
123
123
} ) ;
124
124
125
- return ( toAdd . length + toRemove . length ) > 0 && [ toAdd . length && toAdd , toRemove . length && toRemove ] ;
125
+ return ( toAdd . length + toRemove . length ) > 0 &&
126
+ [ toAdd . length ? toAdd : null , toRemove . length ? toRemove : null ] ;
126
127
}
127
128
128
129
function cachedClassManipulation ( cache , classes , op ) {
@@ -144,6 +145,17 @@ var $AnimateProvider = ['$provide', function($provide) {
144
145
return currentDefer . promise ;
145
146
}
146
147
148
+ function applyStyles ( element , options ) {
149
+ if ( angular . isObject ( options ) ) {
150
+ if ( options . from || options . to ) {
151
+ options = extend ( options . from || { } , options . to || { } ) ;
152
+ } else {
153
+ delete options . tempClasses ;
154
+ }
155
+ element . css ( options ) ;
156
+ }
157
+ }
158
+
147
159
/**
148
160
*
149
161
* @ngdoc service
@@ -176,9 +188,11 @@ var $AnimateProvider = ['$provide', function($provide) {
176
188
* a child (if the after element is not present)
177
189
* @param {DOMElement } after the sibling element which will append the element
178
190
* after itself
191
+ * @param {object= } options an optional collection of styles that will be applied to the element.
179
192
* @return {Promise } the animation callback promise
180
193
*/
181
- enter : function ( element , parent , after ) {
194
+ enter : function ( element , parent , after , options ) {
195
+ applyStyles ( element , options ) ;
182
196
after ? after . after ( element )
183
197
: parent . prepend ( element ) ;
184
198
return asyncPromise ( ) ;
@@ -192,9 +206,10 @@ var $AnimateProvider = ['$provide', function($provide) {
192
206
* @description Removes the element from the DOM. When the function is called a promise
193
207
* is returned that will be resolved at a later time.
194
208
* @param {DOMElement } element the element which will be removed from the DOM
209
+ * @param {object= } options an optional collection of options that will be applied to the element.
195
210
* @return {Promise } the animation callback promise
196
211
*/
197
- leave : function ( element ) {
212
+ leave : function ( element , options ) {
198
213
element . remove ( ) ;
199
214
return asyncPromise ( ) ;
200
215
} ,
@@ -214,12 +229,13 @@ var $AnimateProvider = ['$provide', function($provide) {
214
229
* inserted into (if the after element is not present)
215
230
* @param {DOMElement } after the sibling element where the element will be
216
231
* positioned next to
232
+ * @param {object= } options an optional collection of options that will be applied to the element.
217
233
* @return {Promise } the animation callback promise
218
234
*/
219
- move : function ( element , parent , after ) {
235
+ move : function ( element , parent , after , options ) {
220
236
// Do not remove element before insert. Removing will cause data associated with the
221
237
// element to be dropped. Insert will implicitly do the remove.
222
- return this . enter ( element , parent , after ) ;
238
+ return this . enter ( element , parent , after , options ) ;
223
239
} ,
224
240
225
241
/**
@@ -232,20 +248,23 @@ var $AnimateProvider = ['$provide', function($provide) {
232
248
* @param {DOMElement } element the element which will have the className value
233
249
* added to it
234
250
* @param {string } className the CSS class which will be added to the element
251
+ * @param {object= } options an optional collection of options that will be applied to the element.
235
252
* @return {Promise } the animation callback promise
236
253
*/
237
- addClass : function ( element , className ) {
238
- return this . setClass ( element , className , [ ] ) ;
254
+ addClass : function ( element , className , options ) {
255
+ return this . setClass ( element , className , [ ] , options ) ;
239
256
} ,
240
257
241
- $$addClassImmediately : function ( element , className ) {
258
+ $$addClassImmediately : function ( element , className , options ) {
242
259
element = jqLite ( element ) ;
243
260
className = ! isString ( className )
244
261
? ( isArray ( className ) ? className . join ( ' ' ) : '' )
245
262
: className ;
246
263
forEach ( element , function ( element ) {
247
264
jqLiteAddClass ( element , className ) ;
248
265
} ) ;
266
+ applyStyles ( element , options ) ;
267
+ return asyncPromise ( ) ;
249
268
} ,
250
269
251
270
/**
@@ -258,20 +277,22 @@ var $AnimateProvider = ['$provide', function($provide) {
258
277
* @param {DOMElement } element the element which will have the className value
259
278
* removed from it
260
279
* @param {string } className the CSS class which will be removed from the element
280
+ * @param {object= } options an optional collection of options that will be applied to the element.
261
281
* @return {Promise } the animation callback promise
262
282
*/
263
- removeClass : function ( element , className ) {
264
- return this . setClass ( element , [ ] , className ) ;
283
+ removeClass : function ( element , className , options ) {
284
+ return this . setClass ( element , [ ] , className , options ) ;
265
285
} ,
266
286
267
- $$removeClassImmediately : function ( element , className ) {
287
+ $$removeClassImmediately : function ( element , className , options ) {
268
288
element = jqLite ( element ) ;
269
289
className = ! isString ( className )
270
290
? ( isArray ( className ) ? className . join ( ' ' ) : '' )
271
291
: className ;
272
292
forEach ( element , function ( element ) {
273
293
jqLiteRemoveClass ( element , className ) ;
274
294
} ) ;
295
+ applyStyles ( element , options ) ;
275
296
return asyncPromise ( ) ;
276
297
} ,
277
298
@@ -286,9 +307,10 @@ var $AnimateProvider = ['$provide', function($provide) {
286
307
* removed from it
287
308
* @param {string } add the CSS classes which will be added to the element
288
309
* @param {string } remove the CSS class which will be removed from the element
310
+ * @param {object= } options an optional collection of options that will be applied to the element.
289
311
* @return {Promise } the animation callback promise
290
312
*/
291
- setClass : function ( element , add , remove ) {
313
+ setClass : function ( element , add , remove , options ) {
292
314
var self = this ;
293
315
var STORAGE_KEY = '$$animateClasses' ;
294
316
var createdCache = false ;
@@ -297,9 +319,12 @@ var $AnimateProvider = ['$provide', function($provide) {
297
319
var cache = element . data ( STORAGE_KEY ) ;
298
320
if ( ! cache ) {
299
321
cache = {
300
- classes : { }
322
+ classes : { } ,
323
+ options : options
301
324
} ;
302
325
createdCache = true ;
326
+ } else if ( options && cache . options ) {
327
+ cache . options = angular . extend ( cache . options || { } , options ) ;
303
328
}
304
329
305
330
var classes = cache . classes ;
@@ -320,7 +345,7 @@ var $AnimateProvider = ['$provide', function($provide) {
320
345
if ( cache ) {
321
346
var classes = resolveElementClasses ( element , cache . classes ) ;
322
347
if ( classes ) {
323
- self . $$setClassImmediately ( element , classes [ 0 ] , classes [ 1 ] ) ;
348
+ self . $$setClassImmediately ( element , classes [ 0 ] , classes [ 1 ] , cache . options ) ;
324
349
}
325
350
}
326
351
@@ -332,9 +357,10 @@ var $AnimateProvider = ['$provide', function($provide) {
332
357
return cache . promise ;
333
358
} ,
334
359
335
- $$setClassImmediately : function ( element , add , remove ) {
360
+ $$setClassImmediately : function ( element , add , remove , options ) {
336
361
add && this . $$addClassImmediately ( element , add ) ;
337
362
remove && this . $$removeClassImmediately ( element , remove ) ;
363
+ applyStyles ( element , options ) ;
338
364
return asyncPromise ( ) ;
339
365
} ,
340
366
0 commit comments