@@ -342,7 +342,7 @@ angular.module('ngAnimate', ['ng'])
342
342
var NG_ANIMATE_CHILDREN = '$$ngAnimateChildren' ;
343
343
return function ( scope , element , attrs ) {
344
344
var val = attrs . ngAnimateChildren ;
345
- if ( angular . isString ( val ) && val . length === 0 ) { //empty attribute
345
+ if ( isString ( val ) && val . length === 0 ) { //empty attribute
346
346
element . data ( NG_ANIMATE_CHILDREN , true ) ;
347
347
} else {
348
348
scope . $watch ( val , function ( value ) {
@@ -377,6 +377,7 @@ angular.module('ngAnimate', ['ng'])
377
377
var forEach = angular . forEach ;
378
378
var selectors = $animateProvider . $$selectors ;
379
379
var isArray = angular . isArray ;
380
+ var isString = angular . isString ;
380
381
381
382
var ELEMENT_NODE = 1 ;
382
383
var NG_ANIMATE_STATE = '$$ngAnimateState' ;
@@ -467,6 +468,14 @@ angular.module('ngAnimate', ['ng'])
467
468
return defer . promise ;
468
469
}
469
470
471
+ function parseAnimateOptions ( options ) {
472
+ // some plugin code may still be passing in the callback
473
+ // function as the last param for the $animate methods so
474
+ // it's best to only allow string or array values for now
475
+ if ( isArray ( options ) ) return options ;
476
+ if ( isString ( options ) ) return [ options ] ;
477
+ }
478
+
470
479
function resolveElementClasses ( element , cache , runningAnimations ) {
471
480
runningAnimations = runningAnimations || { } ;
472
481
@@ -779,15 +788,16 @@ angular.module('ngAnimate', ['ng'])
779
788
* @param {DOMElement } afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation
780
789
* @return {Promise } the animation callback promise
781
790
*/
782
- enter : function ( element , parentElement , afterElement ) {
791
+ enter : function ( element , parentElement , afterElement , options ) {
792
+ options = parseAnimateOptions ( options ) ;
783
793
element = angular . element ( element ) ;
784
794
parentElement = prepareElement ( parentElement ) ;
785
795
afterElement = prepareElement ( afterElement ) ;
786
796
787
797
classBasedAnimationsBlocked ( element , true ) ;
788
798
$delegate . enter ( element , parentElement , afterElement ) ;
789
799
return runAnimationPostDigest ( function ( done ) {
790
- return performAnimation ( 'enter' , 'ng-enter' , stripCommentsFromElement ( element ) , parentElement , afterElement , noop , done ) ;
800
+ return performAnimation ( 'enter' , 'ng-enter' , stripCommentsFromElement ( element ) , parentElement , afterElement , noop , options , done ) ;
791
801
} ) ;
792
802
} ,
793
803
@@ -821,7 +831,8 @@ angular.module('ngAnimate', ['ng'])
821
831
* @param {DOMElement } element the element that will be the focus of the leave animation
822
832
* @return {Promise } the animation callback promise
823
833
*/
824
- leave : function ( element ) {
834
+ leave : function ( element , options ) {
835
+ options = parseAnimateOptions ( options ) ;
825
836
element = angular . element ( element ) ;
826
837
827
838
cancelChildAnimations ( element ) ;
@@ -830,7 +841,7 @@ angular.module('ngAnimate', ['ng'])
830
841
return runAnimationPostDigest ( function ( done ) {
831
842
return performAnimation ( 'leave' , 'ng-leave' , stripCommentsFromElement ( element ) , null , null , function ( ) {
832
843
$delegate . leave ( element ) ;
833
- } , done ) ;
844
+ } , options , done ) ;
834
845
} ) ;
835
846
} ,
836
847
@@ -867,7 +878,8 @@ angular.module('ngAnimate', ['ng'])
867
878
* @param {DOMElement } afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation
868
879
* @return {Promise } the animation callback promise
869
880
*/
870
- move : function ( element , parentElement , afterElement ) {
881
+ move : function ( element , parentElement , afterElement , options ) {
882
+ options = parseAnimateOptions ( options ) ;
871
883
element = angular . element ( element ) ;
872
884
parentElement = prepareElement ( parentElement ) ;
873
885
afterElement = prepareElement ( afterElement ) ;
@@ -876,7 +888,7 @@ angular.module('ngAnimate', ['ng'])
876
888
classBasedAnimationsBlocked ( element , true ) ;
877
889
$delegate . move ( element , parentElement , afterElement ) ;
878
890
return runAnimationPostDigest ( function ( done ) {
879
- return performAnimation ( 'move' , 'ng-move' , stripCommentsFromElement ( element ) , parentElement , afterElement , noop , done ) ;
891
+ return performAnimation ( 'move' , 'ng-move' , stripCommentsFromElement ( element ) , parentElement , afterElement , noop , options , done ) ;
880
892
} ) ;
881
893
} ,
882
894
@@ -909,8 +921,8 @@ angular.module('ngAnimate', ['ng'])
909
921
* @param {string } className the CSS class that will be added to the element and then animated
910
922
* @return {Promise } the animation callback promise
911
923
*/
912
- addClass : function ( element , className ) {
913
- return this . setClass ( element , className , [ ] ) ;
924
+ addClass : function ( element , className , options ) {
925
+ return this . setClass ( element , className , [ ] , options ) ;
914
926
} ,
915
927
916
928
/**
@@ -942,8 +954,8 @@ angular.module('ngAnimate', ['ng'])
942
954
* @param {string } className the CSS class that will be animated and then removed from the element
943
955
* @return {Promise } the animation callback promise
944
956
*/
945
- removeClass : function ( element , className ) {
946
- return this . setClass ( element , [ ] , className ) ;
957
+ removeClass : function ( element , className , options ) {
958
+ return this . setClass ( element , [ ] , className , options ) ;
947
959
} ,
948
960
949
961
/**
@@ -973,7 +985,9 @@ angular.module('ngAnimate', ['ng'])
973
985
* CSS classes have been set on the element
974
986
* @return {Promise } the animation callback promise
975
987
*/
976
- setClass : function ( element , add , remove ) {
988
+ setClass : function ( element , add , remove , options ) {
989
+ options = parseAnimateOptions ( options ) ;
990
+
977
991
var STORAGE_KEY = '$$animateClasses' ;
978
992
element = angular . element ( element ) ;
979
993
element = stripCommentsFromElement ( element ) ;
@@ -1007,11 +1021,16 @@ angular.module('ngAnimate', ['ng'])
1007
1021
} ) ;
1008
1022
1009
1023
if ( hasCache ) {
1024
+ if ( options && cache . options ) {
1025
+ cache . options = cache . options . concat ( options ) ;
1026
+ }
1027
+
1010
1028
//the digest cycle will combine all the animations into one function
1011
1029
return cache . promise ;
1012
1030
} else {
1013
1031
element . data ( STORAGE_KEY , cache = {
1014
- classes : classes
1032
+ classes : classes ,
1033
+ options : options
1015
1034
} ) ;
1016
1035
}
1017
1036
@@ -1034,7 +1053,7 @@ angular.module('ngAnimate', ['ng'])
1034
1053
? done ( )
1035
1054
: performAnimation ( 'setClass' , classes , element , parentElement , null , function ( ) {
1036
1055
$delegate . setClass ( element , classes [ 0 ] , classes [ 1 ] ) ;
1037
- } , done ) ;
1056
+ } , cache . options , done ) ;
1038
1057
} ) ;
1039
1058
} ,
1040
1059
@@ -1096,7 +1115,7 @@ angular.module('ngAnimate', ['ng'])
1096
1115
CSS code. Element, parentElement and afterElement are provided DOM elements for the animation
1097
1116
and the onComplete callback will be fired once the animation is fully complete.
1098
1117
*/
1099
- function performAnimation ( animationEvent , className , element , parentElement , afterElement , domOperation , doneCallback ) {
1118
+ function performAnimation ( animationEvent , className , element , parentElement , afterElement , domOperation , options , doneCallback ) {
1100
1119
1101
1120
var noopCancel = noop ;
1102
1121
var runner = animationRunner ( element , animationEvent , className ) ;
@@ -1204,6 +1223,11 @@ angular.module('ngAnimate', ['ng'])
1204
1223
//the ng-animate class does nothing, but it's here to allow for
1205
1224
//parent animations to find and cancel child animations when needed
1206
1225
element . addClass ( NG_ANIMATE_CLASS_NAME ) ;
1226
+ if ( isArray ( options ) ) {
1227
+ forEach ( options , function ( className ) {
1228
+ element . addClass ( className ) ;
1229
+ } ) ;
1230
+ }
1207
1231
1208
1232
var localAnimationCount = globalAnimationCounter ++ ;
1209
1233
totalActiveAnimations ++ ;
@@ -1273,8 +1297,15 @@ angular.module('ngAnimate', ['ng'])
1273
1297
function closeAnimation ( ) {
1274
1298
if ( ! closeAnimation . hasBeenRun ) {
1275
1299
closeAnimation . hasBeenRun = true ;
1300
+ if ( isArray ( options ) ) {
1301
+ forEach ( options , function ( className ) {
1302
+ element . removeClass ( className ) ;
1303
+ } ) ;
1304
+ }
1305
+
1276
1306
var data = element . data ( NG_ANIMATE_STATE ) ;
1277
1307
if ( data ) {
1308
+
1278
1309
/* only structural animations wait for reflow before removing an
1279
1310
animation, but class-based animations don't. An example of this
1280
1311
failing would be when a parent HTML tag has a ng-class attribute
@@ -1539,7 +1570,7 @@ angular.module('ngAnimate', ['ng'])
1539
1570
1540
1571
function parseMaxTime ( str ) {
1541
1572
var maxValue = 0 ;
1542
- var values = angular . isString ( str ) ?
1573
+ var values = isString ( str ) ?
1543
1574
str . split ( / \s * , \s * / ) :
1544
1575
[ ] ;
1545
1576
forEach ( values , function ( value ) {
0 commit comments