@@ -377,6 +377,7 @@ angular.module('ngAnimate', ['ng'])
377377 var forEach = angular . forEach ;
378378 var selectors = $animateProvider . $$selectors ;
379379 var isArray = angular . isArray ;
380+ var isString = angular . isString ;
380381
381382 var ELEMENT_NODE = 1 ;
382383 var NG_ANIMATE_STATE = '$$ngAnimateState' ;
@@ -467,6 +468,14 @@ angular.module('ngAnimate', ['ng'])
467468 return defer . promise ;
468469 }
469470
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+
470479 function resolveElementClasses ( element , cache , runningAnimations ) {
471480 runningAnimations = runningAnimations || { } ;
472481
@@ -784,15 +793,16 @@ angular.module('ngAnimate', ['ng'])
784793 * @param {DOMElement } afterElement the sibling element (which is the previous element) of the element that will be the focus of the enter animation
785794 * @return {Promise } the animation callback promise
786795 */
787- enter : function ( element , parentElement , afterElement ) {
796+ enter : function ( element , parentElement , afterElement , options ) {
797+ options = parseAnimateOptions ( options ) ;
788798 element = angular . element ( element ) ;
789799 parentElement = prepareElement ( parentElement ) ;
790800 afterElement = prepareElement ( afterElement ) ;
791801
792802 classBasedAnimationsBlocked ( element , true ) ;
793803 $delegate . enter ( element , parentElement , afterElement ) ;
794804 return runAnimationPostDigest ( function ( done ) {
795- return performAnimation ( 'enter' , 'ng-enter' , stripCommentsFromElement ( element ) , parentElement , afterElement , noop , done ) ;
805+ return performAnimation ( 'enter' , 'ng-enter' , stripCommentsFromElement ( element ) , parentElement , afterElement , noop , options , done ) ;
796806 } ) ;
797807 } ,
798808
@@ -826,15 +836,16 @@ angular.module('ngAnimate', ['ng'])
826836 * @param {DOMElement } element the element that will be the focus of the leave animation
827837 * @return {Promise } the animation callback promise
828838 */
829- leave : function ( element ) {
839+ leave : function ( element , options ) {
840+ options = parseAnimateOptions ( options ) ;
830841 element = angular . element ( element ) ;
831842
832843 cancelChildAnimations ( element ) ;
833844 classBasedAnimationsBlocked ( element , true ) ;
834845 return runAnimationPostDigest ( function ( done ) {
835846 return performAnimation ( 'leave' , 'ng-leave' , stripCommentsFromElement ( element ) , null , null , function ( ) {
836847 $delegate . leave ( element ) ;
837- } , done ) ;
848+ } , options , done ) ;
838849 } ) ;
839850 } ,
840851
@@ -871,7 +882,8 @@ angular.module('ngAnimate', ['ng'])
871882 * @param {DOMElement } afterElement the sibling element (which is the previous element) of the element that will be the focus of the move animation
872883 * @return {Promise } the animation callback promise
873884 */
874- move : function ( element , parentElement , afterElement ) {
885+ move : function ( element , parentElement , afterElement , options ) {
886+ options = parseAnimateOptions ( options ) ;
875887 element = angular . element ( element ) ;
876888 parentElement = prepareElement ( parentElement ) ;
877889 afterElement = prepareElement ( afterElement ) ;
@@ -880,7 +892,7 @@ angular.module('ngAnimate', ['ng'])
880892 classBasedAnimationsBlocked ( element , true ) ;
881893 $delegate . move ( element , parentElement , afterElement ) ;
882894 return runAnimationPostDigest ( function ( done ) {
883- return performAnimation ( 'move' , 'ng-move' , stripCommentsFromElement ( element ) , parentElement , afterElement , noop , done ) ;
895+ return performAnimation ( 'move' , 'ng-move' , stripCommentsFromElement ( element ) , parentElement , afterElement , noop , options , done ) ;
884896 } ) ;
885897 } ,
886898
@@ -913,8 +925,8 @@ angular.module('ngAnimate', ['ng'])
913925 * @param {string } className the CSS class that will be added to the element and then animated
914926 * @return {Promise } the animation callback promise
915927 */
916- addClass : function ( element , className ) {
917- return this . setClass ( element , className , [ ] ) ;
928+ addClass : function ( element , className , options ) {
929+ return this . setClass ( element , className , [ ] , options ) ;
918930 } ,
919931
920932 /**
@@ -946,8 +958,8 @@ angular.module('ngAnimate', ['ng'])
946958 * @param {string } className the CSS class that will be animated and then removed from the element
947959 * @return {Promise } the animation callback promise
948960 */
949- removeClass : function ( element , className ) {
950- return this . setClass ( element , [ ] , className ) ;
961+ removeClass : function ( element , className , options ) {
962+ return this . setClass ( element , [ ] , className , options ) ;
951963 } ,
952964
953965 /**
@@ -977,7 +989,9 @@ angular.module('ngAnimate', ['ng'])
977989 * CSS classes have been set on the element
978990 * @return {Promise } the animation callback promise
979991 */
980- setClass : function ( element , add , remove ) {
992+ setClass : function ( element , add , remove , options ) {
993+ options = parseAnimateOptions ( options ) ;
994+
981995 var STORAGE_KEY = '$$animateClasses' ;
982996 element = angular . element ( element ) ;
983997 element = stripCommentsFromElement ( element ) ;
@@ -1014,11 +1028,16 @@ angular.module('ngAnimate', ['ng'])
10141028 } ) ;
10151029
10161030 if ( hasCache ) {
1031+ if ( options && cache . options ) {
1032+ cache . options = cache . options . concat ( options ) ;
1033+ }
1034+
10171035 //the digest cycle will combine all the animations into one function
10181036 return cache . promise ;
10191037 } else {
10201038 element . data ( STORAGE_KEY , cache = {
1021- classes : classes
1039+ classes : classes ,
1040+ options : options
10221041 } ) ;
10231042 }
10241043
@@ -1042,7 +1061,7 @@ angular.module('ngAnimate', ['ng'])
10421061 : performAnimation ( 'setClass' , classes , element , parentElement , null , function ( ) {
10431062 if ( classes [ 0 ] ) $delegate . $$addClassImmediately ( element , classes [ 0 ] ) ;
10441063 if ( classes [ 1 ] ) $delegate . $$removeClassImmediately ( element , classes [ 1 ] ) ;
1045- } , done ) ;
1064+ } , cache . options , done ) ;
10461065 } ) ;
10471066 } ,
10481067
@@ -1104,7 +1123,7 @@ angular.module('ngAnimate', ['ng'])
11041123 CSS code. Element, parentElement and afterElement are provided DOM elements for the animation
11051124 and the onComplete callback will be fired once the animation is fully complete.
11061125 */
1107- function performAnimation ( animationEvent , className , element , parentElement , afterElement , domOperation , doneCallback ) {
1126+ function performAnimation ( animationEvent , className , element , parentElement , afterElement , domOperation , options , doneCallback ) {
11081127
11091128 var noopCancel = noop ;
11101129 var runner = animationRunner ( element , animationEvent , className ) ;
@@ -1212,6 +1231,11 @@ angular.module('ngAnimate', ['ng'])
12121231 //the ng-animate class does nothing, but it's here to allow for
12131232 //parent animations to find and cancel child animations when needed
12141233 element . addClass ( NG_ANIMATE_CLASS_NAME ) ;
1234+ if ( isArray ( options ) ) {
1235+ forEach ( options , function ( className ) {
1236+ element . addClass ( className ) ;
1237+ } ) ;
1238+ }
12151239
12161240 var localAnimationCount = globalAnimationCounter ++ ;
12171241 totalActiveAnimations ++ ;
@@ -1281,8 +1305,15 @@ angular.module('ngAnimate', ['ng'])
12811305 function closeAnimation ( ) {
12821306 if ( ! closeAnimation . hasBeenRun ) {
12831307 closeAnimation . hasBeenRun = true ;
1308+ if ( isArray ( options ) ) {
1309+ forEach ( options , function ( className ) {
1310+ element . removeClass ( className ) ;
1311+ } ) ;
1312+ }
1313+
12841314 var data = element . data ( NG_ANIMATE_STATE ) ;
12851315 if ( data ) {
1316+
12861317 /* only structural animations wait for reflow before removing an
12871318 animation, but class-based animations don't. An example of this
12881319 failing would be when a parent HTML tag has a ng-class attribute
@@ -1547,7 +1578,7 @@ angular.module('ngAnimate', ['ng'])
15471578
15481579 function parseMaxTime ( str ) {
15491580 var maxValue = 0 ;
1550- var values = angular . isString ( str ) ?
1581+ var values = isString ( str ) ?
15511582 str . split ( / \s * , \s * / ) :
15521583 [ ] ;
15531584 forEach ( values , function ( value ) {
0 commit comments