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