feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
'use strict' ;
describe ( "ngAnimate" , function ( ) {
beforeEach ( module ( 'ngAnimate' ) ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should disable animations on bootstrap for structural animations even after the first digest has passed" , function ( ) {
var hasBeenAnimated = false ;
module ( function ( $animateProvider ) {
$animateProvider . register ( '.my-structrual-animation' , function ( ) {
return {
enter : function ( element , done ) {
hasBeenAnimated = true ;
done ( ) ;
} ,
leave : function ( element , done ) {
hasBeenAnimated = true ;
done ( ) ;
}
}
} ) ;
} ) ;
inject ( function ( $rootScope , $compile , $animate , $rootElement , $document ) {
var element = $compile ( '<div class="my-structrual-animation">...</div>' ) ( $rootScope ) ;
$rootElement . append ( element ) ;
jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
$animate . enter ( element , $rootElement ) ;
2013-11-07 18:44:27 +00:00
$rootScope . $digest ( ) ;
2013-08-21 19:03:41 +00:00
2013-11-25 18:40:52 +00:00
expect ( hasBeenAnimated ) . toBe ( false ) ;
$animate . leave ( element ) ;
$rootScope . $digest ( ) ;
expect ( hasBeenAnimated ) . toBe ( true ) ;
} ) ;
2013-08-21 19:03:41 +00:00
} ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
//we use another describe block because the before/after operations below
//are used across all animations tests and we don't want that same behavior
//to be used on the root describe block at the start of the animateSpec.js file
describe ( '' , function ( ) {
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
var ss , body ;
beforeEach ( module ( function ( ) {
body = jqLite ( document . body ) ;
return function ( $window , $document , $animate , $timeout , $rootScope ) {
ss = createMockStyleSheet ( $document , $window ) ;
try {
$timeout . flush ( ) ;
} catch ( e ) { }
$animate . enabled ( true ) ;
$rootScope . $digest ( ) ;
} ;
} ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
afterEach ( function ( ) {
if ( ss ) {
ss . destroy ( ) ;
}
dealoc ( body ) ;
} ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
describe ( "$animate" , function ( ) {
var element , $rootElement ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
function html ( html ) {
body . append ( $rootElement ) ;
$rootElement . html ( html ) ;
element = $rootElement . children ( ) . eq ( 0 ) ;
return element ;
}
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
describe ( "enable / disable" , function ( ) {
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
it ( "should work for all animations" , inject ( function ( $animate ) {
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( $animate . enabled ( ) ) . toBe ( true ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( $animate . enabled ( 0 ) ) . toBe ( false ) ;
expect ( $animate . enabled ( ) ) . toBe ( false ) ;
2013-10-22 05:53:40 +00:00
2013-11-25 18:40:52 +00:00
expect ( $animate . enabled ( 1 ) ) . toBe ( true ) ;
expect ( $animate . enabled ( ) ) . toBe ( true ) ;
} ) ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( 'should place a hard disable on all child animations' , function ( ) {
var count = 0 ;
module ( function ( $animateProvider ) {
$animateProvider . register ( '.animated' , function ( ) {
return {
addClass : function ( element , className , done ) {
count ++ ;
done ( ) ;
}
2013-10-22 05:53:40 +00:00
}
2013-11-25 18:40:52 +00:00
} ) ;
2013-10-22 05:53:40 +00:00
} ) ;
2013-11-25 18:40:52 +00:00
inject ( function ( $compile , $rootScope , $animate , $sniffer , $rootElement , $timeout ) {
$animate . enabled ( true ) ;
2013-10-22 05:53:40 +00:00
2013-11-25 18:40:52 +00:00
var elm1 = $compile ( '<div class="animated"></div>' ) ( $rootScope ) ;
var elm2 = $compile ( '<div class="animated"></div>' ) ( $rootScope ) ;
$rootElement . append ( elm1 ) ;
angular . element ( document . body ) . append ( $rootElement ) ;
2013-10-22 05:53:40 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( elm1 , 'klass' ) ;
expect ( count ) . toBe ( 1 ) ;
2013-10-22 05:53:40 +00:00
2013-11-25 18:40:52 +00:00
$animate . enabled ( false ) ;
2013-10-22 05:53:40 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( elm1 , 'klass2' ) ;
expect ( count ) . toBe ( 1 ) ;
2013-10-22 05:53:40 +00:00
2013-11-25 18:40:52 +00:00
$animate . enabled ( true ) ;
2013-10-22 05:53:40 +00:00
2013-11-25 18:40:52 +00:00
elm1 . append ( elm2 ) ;
2013-10-22 05:53:40 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( elm2 , 'klass' ) ;
expect ( count ) . toBe ( 2 ) ;
2013-10-22 05:53:40 +00:00
2013-11-25 18:40:52 +00:00
$animate . enabled ( false , elm1 ) ;
2013-10-22 05:53:40 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( elm2 , 'klass2' ) ;
expect ( count ) . toBe ( 2 ) ;
2013-10-29 04:44:06 +00:00
2013-11-25 18:40:52 +00:00
var root = angular . element ( $rootElement [ 0 ] ) ;
$rootElement . addClass ( 'animated' ) ;
$animate . addClass ( root , 'klass2' ) ;
expect ( count ) . toBe ( 3 ) ;
} ) ;
2013-10-22 05:53:40 +00:00
} ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( 'should skip animations if the element is attached to the $rootElement' , function ( ) {
var count = 0 ;
module ( function ( $animateProvider ) {
$animateProvider . register ( '.animated' , function ( ) {
return {
addClass : function ( element , className , done ) {
count ++ ;
done ( ) ;
}
2013-10-22 05:53:40 +00:00
}
2013-11-25 18:40:52 +00:00
} ) ;
2013-10-22 05:53:40 +00:00
} ) ;
2013-11-25 18:40:52 +00:00
inject ( function ( $compile , $rootScope , $animate , $sniffer , $rootElement , $timeout ) {
$animate . enabled ( true ) ;
2013-10-22 05:53:40 +00:00
2013-11-25 18:40:52 +00:00
var elm1 = $compile ( '<div class="animated"></div>' ) ( $rootScope ) ;
2013-10-22 05:53:40 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( elm1 , 'klass2' ) ;
expect ( count ) . toBe ( 0 ) ;
} ) ;
2013-10-22 05:53:40 +00:00
} ) ;
2013-10-28 16:43:41 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( 'should check enable/disable animations up until the $rootElement element' , function ( ) {
var rootElm = jqLite ( '<div></div>' ) ;
var captured = false ;
module ( function ( $provide , $animateProvider ) {
$provide . value ( '$rootElement' , rootElm ) ;
$animateProvider . register ( '.capture-animation' , function ( ) {
return {
addClass : function ( element , className , done ) {
captured = true ;
done ( ) ;
}
2013-10-28 16:43:41 +00:00
}
2013-11-25 18:40:52 +00:00
} ) ;
2013-10-28 16:43:41 +00:00
} ) ;
2013-11-25 18:40:52 +00:00
inject ( function ( $animate , $rootElement , $rootScope , $compile , $timeout ) {
var initialState ;
angular . bootstrap ( rootElm , [ 'ngAnimate' ] ) ;
2013-10-28 16:43:41 +00:00
2013-11-25 18:40:52 +00:00
$animate . enabled ( true ) ;
2013-10-28 16:43:41 +00:00
2013-11-25 18:40:52 +00:00
var element = $compile ( '<div class="capture-animation"></div>' ) ( $rootScope ) ;
rootElm . append ( element ) ;
2013-10-28 16:43:41 +00:00
2013-11-25 18:40:52 +00:00
expect ( captured ) . toBe ( false ) ;
$animate . addClass ( element , 'red' ) ;
expect ( captured ) . toBe ( true ) ;
2013-10-28 16:43:41 +00:00
2013-11-25 18:40:52 +00:00
captured = false ;
$animate . enabled ( false ) ;
2013-10-28 16:43:41 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( element , 'blue' ) ;
expect ( captured ) . toBe ( false ) ;
2013-10-28 16:43:41 +00:00
2013-11-25 18:40:52 +00:00
//clean up the mess
$animate . enabled ( false , rootElm ) ;
dealoc ( rootElm ) ;
} ) ;
2013-10-28 16:43:41 +00:00
} ) ;
} ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
describe ( "with polyfill" , function ( ) {
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var child , after ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
beforeEach ( function ( ) {
module ( function ( $animateProvider ) {
$animateProvider . register ( '.custom' , function ( ) {
return {
start : function ( element , done ) {
done ( ) ;
}
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
}
2013-11-25 18:40:52 +00:00
} ) ;
$animateProvider . register ( '.custom-delay' , function ( $timeout ) {
function animate ( element , done ) {
done = arguments . length == 3 ? arguments [ 2 ] : done ;
$timeout ( done , 2000 , false ) ;
return function ( ) {
element . addClass ( 'animation-cancelled' ) ;
}
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
}
2013-11-25 18:40:52 +00:00
return {
leave : animate ,
addClass : animate ,
removeClass : animate
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
}
2013-11-25 18:40:52 +00:00
} ) ;
$animateProvider . register ( '.custom-long-delay' , function ( $timeout ) {
function animate ( element , done ) {
done = arguments . length == 3 ? arguments [ 2 ] : done ;
$timeout ( done , 20000 , false ) ;
return function ( cancelled ) {
element . addClass ( cancelled ? 'animation-cancelled' : 'animation-ended' ) ;
}
}
return {
leave : animate ,
addClass : animate ,
removeClass : animate
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
}
2013-08-21 19:03:41 +00:00
} ) ;
2013-11-25 18:40:52 +00:00
$animateProvider . register ( '.setup-memo' , function ( ) {
return {
removeClass : function ( element , className , done ) {
element . text ( 'memento' ) ;
done ( ) ;
}
}
} ) ;
return function ( $animate , $compile , $rootScope , $rootElement ) {
element = $compile ( '<div></div>' ) ( $rootScope ) ;
2013-08-21 19:03:41 +00:00
2013-11-25 18:40:52 +00:00
forEach ( [ '.ng-hide-add' , '.ng-hide-remove' , '.ng-enter' , '.ng-leave' , '.ng-move' ] , function ( selector ) {
ss . addRule ( selector , '-webkit-transition:1s linear all;' +
'transition:1s linear all;' ) ;
} ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
child = $compile ( '<div>...</div>' ) ( $rootScope ) ;
jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
element . append ( child ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
after = $compile ( '<div></div>' ) ( $rootScope ) ;
$rootElement . append ( element ) ;
} ;
} ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
} )
2013-07-22 19:37:45 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should animate the enter animation event" ,
inject ( function ( $animate , $rootScope , $sniffer , $timeout ) {
element [ 0 ] . removeChild ( child [ 0 ] ) ;
2013-08-21 19:03:41 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . contents ( ) . length ) . toBe ( 0 ) ;
$animate . enter ( child , element ) ;
$rootScope . $digest ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
if ( $sniffer . transitions ) {
2013-11-04 21:23:56 +00:00
$timeout . flush ( ) ;
2013-11-25 18:40:52 +00:00
expect ( child . hasClass ( 'ng-enter' ) ) . toBe ( true ) ;
expect ( child . hasClass ( 'ng-enter-active' ) ) . toBe ( true ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
}
2013-08-21 19:03:41 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . contents ( ) . length ) . toBe ( 1 ) ;
} ) ) ;
2013-08-21 19:03:41 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should animate the leave animation event" ,
inject ( function ( $animate , $rootScope , $sniffer , $timeout ) {
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . contents ( ) . length ) . toBe ( 1 ) ;
$animate . leave ( child ) ;
$rootScope . $digest ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
if ( $sniffer . transitions ) {
2013-11-04 21:23:56 +00:00
$timeout . flush ( ) ;
2013-11-25 18:40:52 +00:00
expect ( child . hasClass ( 'ng-leave' ) ) . toBe ( true ) ;
expect ( child . hasClass ( 'ng-leave-active' ) ) . toBe ( true ) ;
browserTrigger ( child , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
}
2013-11-25 18:40:52 +00:00
expect ( element . contents ( ) . length ) . toBe ( 0 ) ;
} ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should animate the move animation event" ,
inject ( function ( $animate , $compile , $rootScope , $timeout , $sniffer ) {
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$rootScope . $digest ( ) ;
2013-10-16 13:15:21 +00:00
element . empty ( ) ;
2013-11-25 18:40:52 +00:00
var child1 = $compile ( '<div>1</div>' ) ( $rootScope ) ;
var child2 = $compile ( '<div>2</div>' ) ( $rootScope ) ;
element . append ( child1 ) ;
element . append ( child2 ) ;
expect ( element . text ( ) ) . toBe ( '12' ) ;
$animate . move ( child1 , element , child2 ) ;
$rootScope . $digest ( ) ;
if ( $sniffer . transitions ) {
2013-11-04 21:23:56 +00:00
$timeout . flush ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
}
2013-11-25 18:40:52 +00:00
expect ( element . text ( ) ) . toBe ( '21' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
} ) ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should animate the show animation event" ,
inject ( function ( $animate , $rootScope , $sniffer , $timeout ) {
2013-07-22 19:37:45 +00:00
2013-11-25 18:40:52 +00:00
$rootScope . $digest ( ) ;
child . addClass ( 'ng-hide' ) ;
expect ( child ) . toBeHidden ( ) ;
$animate . removeClass ( child , 'ng-hide' ) ;
if ( $sniffer . transitions ) {
2013-11-04 21:23:56 +00:00
$timeout . flush ( ) ;
2013-11-25 18:40:52 +00:00
expect ( child . hasClass ( 'ng-hide-remove' ) ) . toBe ( true ) ;
expect ( child . hasClass ( 'ng-hide-remove-active' ) ) . toBe ( true ) ;
browserTrigger ( child , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
}
2013-11-25 18:40:52 +00:00
expect ( child . hasClass ( 'ng-hide-remove' ) ) . toBe ( false ) ;
expect ( child . hasClass ( 'ng-hide-remove-active' ) ) . toBe ( false ) ;
expect ( child ) . toBeShown ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
} ) ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should animate the hide animation event" ,
inject ( function ( $animate , $rootScope , $sniffer , $timeout ) {
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$rootScope . $digest ( ) ;
expect ( child ) . toBeShown ( ) ;
$animate . addClass ( child , 'ng-hide' ) ;
if ( $sniffer . transitions ) {
$timeout . flush ( ) ;
expect ( child . hasClass ( 'ng-hide-add' ) ) . toBe ( true ) ;
expect ( child . hasClass ( 'ng-hide-add-active' ) ) . toBe ( true ) ;
browserTrigger ( child , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
}
expect ( child ) . toBeHidden ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
} ) ) ;
2013-10-25 18:20:35 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should assign the ng-event className to all animation events when transitions/keyframes are used" ,
inject ( function ( $animate , $sniffer , $rootScope , $timeout ) {
2013-10-25 18:20:35 +00:00
2013-11-25 18:40:52 +00:00
if ( ! $sniffer . transitions ) return ;
2013-10-25 18:20:35 +00:00
2013-11-25 18:40:52 +00:00
$rootScope . $digest ( ) ;
element [ 0 ] . removeChild ( child [ 0 ] ) ;
2013-10-25 18:20:35 +00:00
2013-11-25 18:40:52 +00:00
//enter
$animate . enter ( child , element ) ;
2013-10-25 18:20:35 +00:00
$rootScope . $digest ( ) ;
$timeout . flush ( ) ;
2013-11-25 18:40:52 +00:00
expect ( child . attr ( 'class' ) ) . toContain ( 'ng-enter' ) ;
expect ( child . attr ( 'class' ) ) . toContain ( 'ng-enter-active' ) ;
browserTrigger ( child , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
$timeout . flush ( ) ;
2013-10-25 18:20:35 +00:00
2013-11-25 18:40:52 +00:00
//move
element . append ( after ) ;
$animate . move ( child , element , after ) ;
2013-10-25 18:20:35 +00:00
$rootScope . $digest ( ) ;
$timeout . flush ( ) ;
2013-11-25 18:40:52 +00:00
expect ( child . attr ( 'class' ) ) . toContain ( 'ng-move' ) ;
expect ( child . attr ( 'class' ) ) . toContain ( 'ng-move-active' ) ;
browserTrigger ( child , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
$timeout . flush ( ) ;
2013-10-31 18:49:06 +00:00
2013-11-25 18:40:52 +00:00
//hide
$animate . addClass ( child , 'ng-hide' ) ;
$timeout . flush ( ) ;
expect ( child . attr ( 'class' ) ) . toContain ( 'ng-hide-add' ) ;
expect ( child . attr ( 'class' ) ) . toContain ( 'ng-hide-add-active' ) ;
browserTrigger ( child , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
2013-10-31 18:49:06 +00:00
2013-11-25 18:40:52 +00:00
//show
$animate . removeClass ( child , 'ng-hide' ) ;
$timeout . flush ( ) ;
expect ( child . attr ( 'class' ) ) . toContain ( 'ng-hide-remove' ) ;
expect ( child . attr ( 'class' ) ) . toContain ( 'ng-hide-remove-active' ) ;
browserTrigger ( child , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
2013-10-31 18:49:06 +00:00
2013-11-25 18:40:52 +00:00
//leave
$animate . leave ( child ) ;
2013-10-31 18:49:06 +00:00
$rootScope . $digest ( ) ;
$timeout . flush ( ) ;
2013-11-25 18:40:52 +00:00
expect ( child . attr ( 'class' ) ) . toContain ( 'ng-leave' ) ;
expect ( child . attr ( 'class' ) ) . toContain ( 'ng-leave-active' ) ;
browserTrigger ( child , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
} ) ) ;
2013-10-31 18:49:06 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should not run if animations are disabled" ,
inject ( function ( $animate , $rootScope , $timeout , $sniffer ) {
2013-10-31 21:09:49 +00:00
2013-11-25 18:40:52 +00:00
$animate . enabled ( false ) ;
2013-10-31 21:09:49 +00:00
2013-11-25 18:40:52 +00:00
$rootScope . $digest ( ) ;
2013-10-31 21:09:49 +00:00
2013-11-25 18:40:52 +00:00
element . addClass ( 'setup-memo' ) ;
2013-10-31 21:09:49 +00:00
2013-11-25 18:40:52 +00:00
element . text ( '123' ) ;
expect ( element . text ( ) ) . toBe ( '123' ) ;
$animate . removeClass ( element , 'ng-hide' ) ;
expect ( element . text ( ) ) . toBe ( '123' ) ;
2013-10-31 21:09:49 +00:00
2013-11-25 18:40:52 +00:00
$animate . enabled ( true ) ;
2013-10-31 21:09:49 +00:00
2013-11-25 18:40:52 +00:00
element . addClass ( 'ng-hide' ) ;
$animate . removeClass ( element , 'ng-hide' ) ;
if ( $sniffer . transitions ) {
$timeout . flush ( ) ;
}
expect ( element . text ( ) ) . toBe ( 'memento' ) ;
} ) ) ;
2013-10-31 21:09:49 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should only call done() once and right away if another animation takes place in between" ,
inject ( function ( $animate , $rootScope , $sniffer , $timeout ) {
2013-10-31 21:09:49 +00:00
2013-11-25 18:40:52 +00:00
element . append ( child ) ;
child . addClass ( 'custom-delay' ) ;
2013-10-31 21:09:49 +00:00
2013-11-25 18:40:52 +00:00
expect ( element ) . toBeShown ( ) ;
$animate . addClass ( child , 'ng-hide' ) ;
if ( $sniffer . transitions ) {
expect ( child ) . toBeShown ( ) ;
}
2013-10-31 21:09:49 +00:00
2013-11-25 18:40:52 +00:00
$animate . leave ( child ) ;
2013-10-31 21:09:49 +00:00
$rootScope . $digest ( ) ;
$timeout . flush ( ) ;
2013-11-25 18:40:52 +00:00
expect ( child ) . toBeHidden ( ) ; //hides instantly
2013-10-31 21:09:49 +00:00
2013-11-25 18:40:52 +00:00
//lets change this to prove that done doesn't fire anymore for the previous hide() operation
child . css ( 'display' , 'block' ) ;
child . removeClass ( 'ng-hide' ) ;
2013-10-31 21:09:49 +00:00
2013-11-25 18:40:52 +00:00
if ( $sniffer . transitions ) {
expect ( element . children ( ) . length ) . toBe ( 1 ) ; //still animating
browserTrigger ( child , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
}
$timeout . flush ( 2000 ) ;
$timeout . flush ( 2000 ) ;
expect ( child ) . toBeShown ( ) ;
2013-10-31 21:09:49 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . children ( ) . length ) . toBe ( 0 ) ;
2013-10-31 21:09:49 +00:00
} ) ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should retain existing styles of the animated element" ,
inject ( function ( $animate , $rootScope , $sniffer , $timeout ) {
element . append ( child ) ;
child . attr ( 'style' , 'width: 20px' ) ;
$animate . addClass ( child , 'ng-hide' ) ;
$animate . leave ( child ) ;
$rootScope . $digest ( ) ;
2013-11-06 06:57:34 +00:00
2013-11-25 18:40:52 +00:00
if ( $sniffer . transitions ) {
$timeout . flush ( ) ;
2013-11-06 06:57:34 +00:00
2013-11-25 18:40:52 +00:00
//this is to verify that the existing style is appended with a semicolon automatically
expect ( child . attr ( 'style' ) ) . toMatch ( /width: 20px;.+?/i ) ;
browserTrigger ( child , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
}
expect ( child . attr ( 'style' ) ) . toMatch ( /width: 20px/i ) ;
} ) ) ;
2013-11-06 06:57:34 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should call the cancel callback when another animation is called on the same element" ,
inject ( function ( $animate , $rootScope , $sniffer , $timeout ) {
2013-11-06 06:57:34 +00:00
2013-11-25 18:40:52 +00:00
element . append ( child ) ;
2013-11-06 06:57:34 +00:00
2013-11-25 18:40:52 +00:00
child . addClass ( 'custom-delay ng-hide' ) ;
$animate . removeClass ( child , 'ng-hide' ) ;
if ( $sniffer . transitions ) {
browserTrigger ( child , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
}
$timeout . flush ( 2000 ) ;
2013-11-06 06:57:34 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( child , 'ng-hide' ) ;
2013-11-06 06:57:34 +00:00
2013-11-25 18:40:52 +00:00
expect ( child . hasClass ( 'animation-cancelled' ) ) . toBe ( true ) ;
} ) ) ;
2013-11-06 06:57:34 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should skip a class-based animation if the same element already has an ongoing structural animation" ,
inject ( function ( $animate , $rootScope , $sniffer , $timeout ) {
2013-11-06 06:57:34 +00:00
2013-11-25 18:40:52 +00:00
var completed = false ;
$animate . enter ( child , element , null , function ( ) {
completed = true ;
} ) ;
$rootScope . $digest ( ) ;
2013-11-06 06:57:34 +00:00
2013-11-25 18:40:52 +00:00
expect ( completed ) . toBe ( false ) ;
2013-11-06 06:57:34 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( child , 'green' ) ;
expect ( element . hasClass ( 'green' ) ) ;
expect ( completed ) . toBe ( false ) ;
if ( $sniffer . transitions ) {
$timeout . flush ( ) ;
browserTrigger ( child , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
}
2013-11-06 06:57:34 +00:00
$timeout . flush ( ) ;
2013-11-25 18:40:52 +00:00
expect ( completed ) . toBe ( true ) ;
} ) ) ;
2013-11-06 06:57:34 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should fire the cancel/end function with the correct flag in the parameters" ,
inject ( function ( $animate , $rootScope , $sniffer , $timeout ) {
2013-11-06 06:57:34 +00:00
2013-11-25 18:40:52 +00:00
element . append ( child ) ;
2013-11-06 06:57:34 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( child , 'custom-delay' ) ;
$animate . addClass ( child , 'custom-long-delay' ) ;
2013-11-06 06:57:34 +00:00
2013-11-25 18:40:52 +00:00
expect ( child . hasClass ( 'animation-cancelled' ) ) . toBe ( true ) ;
expect ( child . hasClass ( 'animation-ended' ) ) . toBe ( false ) ;
2013-11-06 06:57:34 +00:00
$timeout . flush ( ) ;
2013-11-25 18:40:52 +00:00
expect ( child . hasClass ( 'animation-ended' ) ) . toBe ( true ) ;
} ) ) ;
it ( "should NOT clobber all data on an element when animation is finished" ,
inject ( function ( $animate ) {
child . css ( 'display' , 'none' ) ;
element . data ( 'foo' , 'bar' ) ;
2013-11-06 06:57:34 +00:00
2013-11-25 18:40:52 +00:00
$animate . removeClass ( element , 'ng-hide' ) ;
$animate . addClass ( element , 'ng-hide' ) ;
expect ( element . data ( 'foo' ) ) . toEqual ( 'bar' ) ;
2013-11-06 06:57:34 +00:00
} ) ) ;
2013-11-25 18:40:52 +00:00
it ( "should allow multiple JS animations which run in parallel" ,
2013-07-22 19:37:45 +00:00
inject ( function ( $animate , $rootScope , $compile , $sniffer , $timeout ) {
2013-11-25 18:40:52 +00:00
$animate . addClass ( element , 'custom-delay custom-long-delay' ) ;
$timeout . flush ( 2000 ) ;
$timeout . flush ( 20000 ) ;
expect ( element . hasClass ( 'custom-delay' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'custom-long-delay' ) ) . toBe ( true ) ;
} ) ) ;
2013-08-21 19:03:41 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should allow both multiple JS and CSS animations which run in parallel" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $timeout , _$rootElement _ ) {
$rootElement = _$rootElement _ ;
ss . addRule ( '.ng-hide-add' , '-webkit-transition:1s linear all;' +
'transition:1s linear all;' ) ;
ss . addRule ( '.ng-hide-remove' , '-webkit-transition:1s linear all;' +
'transition:1s linear all;' ) ;
2013-08-21 19:03:41 +00:00
element = $compile ( html ( '<div>1</div>' ) ) ( $rootScope ) ;
2013-11-25 18:40:52 +00:00
element . addClass ( 'custom-delay custom-long-delay' ) ;
$rootScope . $digest ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-07-24 03:02:15 +00:00
$animate . removeClass ( element , 'ng-hide' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
if ( $sniffer . transitions ) {
2013-11-04 20:55:01 +00:00
browserTrigger ( element , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
}
2013-11-25 18:40:52 +00:00
$timeout . flush ( 2000 ) ;
$timeout . flush ( 20000 ) ;
expect ( element . hasClass ( 'custom-delay' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'custom-delay-add' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'custom-delay-add-active' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'custom-long-delay' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'custom-long-delay-add' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'custom-long-delay-add-active' ) ) . toBe ( false ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
} ) ) ;
2013-11-25 18:40:52 +00:00
} ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
describe ( "with CSS3" , function ( ) {
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
beforeEach ( function ( ) {
module ( function ( ) {
return function ( _$rootElement _ ) {
$rootElement = _$rootElement _ ;
} ;
} )
} ) ;
2013-08-21 19:03:41 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
describe ( "Animations" , function ( ) {
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should properly detect and make use of CSS Animations" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $timeout ) {
2013-08-21 19:03:41 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.ng-hide-add' ,
'-webkit-animation: some_animation 4s linear 0s 1 alternate;' +
'animation: some_animation 4s linear 0s 1 alternate;' ) ;
ss . addRule ( '.ng-hide-remove' ,
'-webkit-animation: some_animation 4s linear 0s 1 alternate;' +
'animation: some_animation 4s linear 0s 1 alternate;' ) ;
element = $compile ( html ( '<div>1</div>' ) ) ( $rootScope ) ;
2013-08-21 19:03:41 +00:00
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
element . addClass ( 'ng-hide' ) ;
2013-11-25 18:40:52 +00:00
expect ( element ) . toBeHidden ( ) ;
2013-11-04 21:23:56 +00:00
2013-07-24 03:02:15 +00:00
$animate . removeClass ( element , 'ng-hide' ) ;
2013-11-25 18:40:52 +00:00
if ( $sniffer . animations ) {
2013-11-04 21:23:56 +00:00
$timeout . flush ( ) ;
2013-11-25 18:40:52 +00:00
browserTrigger ( element , 'animationend' , { timeStamp : Date . now ( ) + 4000 , elapsedTime : 4 } ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
}
expect ( element ) . toBeShown ( ) ;
} ) ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should properly detect and make use of CSS Animations with multiple iterations" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $timeout ) {
var style = '-webkit-animation-duration: 2s;' +
'-webkit-animation-iteration-count: 3;' +
'animation-duration: 2s;' +
'animation-iteration-count: 3;' ;
2013-08-21 19:03:41 +00:00
ss . addRule ( '.ng-hide-add' , style ) ;
ss . addRule ( '.ng-hide-remove' , style ) ;
2013-11-25 18:40:52 +00:00
element = $compile ( html ( '<div>1</div>' ) ) ( $rootScope ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
element . addClass ( 'ng-hide' ) ;
expect ( element ) . toBeHidden ( ) ;
2013-07-24 03:02:15 +00:00
$animate . removeClass ( element , 'ng-hide' ) ;
2013-11-25 18:40:52 +00:00
if ( $sniffer . animations ) {
2013-11-04 21:23:56 +00:00
$timeout . flush ( ) ;
2013-11-25 18:40:52 +00:00
browserTrigger ( element , 'animationend' , { timeStamp : Date . now ( ) + 6000 , elapsedTime : 6 } ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
}
expect ( element ) . toBeShown ( ) ;
2013-11-25 18:40:52 +00:00
} ) ) ;
2013-11-10 21:36:47 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should not consider the animation delay is provided" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $timeout ) {
var style = '-webkit-animation-duration: 2s;' +
'-webkit-animation-delay: 10s;' +
'-webkit-animation-iteration-count: 5;' +
'animation-duration: 2s;' +
'animation-delay: 10s;' +
'animation-iteration-count: 5;' ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-08-21 19:03:41 +00:00
ss . addRule ( '.ng-hide-add' , style ) ;
ss . addRule ( '.ng-hide-remove' , style ) ;
2013-11-25 18:40:52 +00:00
element = $compile ( html ( '<div>1</div>' ) ) ( $rootScope ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
element . addClass ( 'ng-hide' ) ;
expect ( element ) . toBeHidden ( ) ;
2013-07-24 03:02:15 +00:00
$animate . removeClass ( element , 'ng-hide' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
if ( $sniffer . transitions ) {
2013-11-04 21:23:56 +00:00
$timeout . flush ( ) ;
2013-11-25 18:40:52 +00:00
browserTrigger ( element , 'animationend' , { timeStamp : Date . now ( ) + 20000 , elapsedTime : 10 } ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
}
expect ( element ) . toBeShown ( ) ;
2013-11-25 18:40:52 +00:00
} ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should skip animations if disabled and run when enabled" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $timeout ) {
$animate . enabled ( false ) ;
var style = '-webkit-animation: some_animation 2s linear 0s 1 alternate;' +
'animation: some_animation 2s linear 0s 1 alternate;' ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-08-21 19:03:41 +00:00
ss . addRule ( '.ng-hide-add' , style ) ;
ss . addRule ( '.ng-hide-remove' , style ) ;
element = $compile ( html ( '<div>1</div>' ) ) ( $rootScope ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
element . addClass ( 'ng-hide' ) ;
2013-11-25 18:40:52 +00:00
expect ( element ) . toBeHidden ( ) ;
2013-07-24 03:02:15 +00:00
$animate . removeClass ( element , 'ng-hide' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
expect ( element ) . toBeShown ( ) ;
2013-11-25 18:40:52 +00:00
} ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should finish the previous animation when a new animation is started" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $timeout ) {
var style = '-webkit-animation: some_animation 2s linear 0s 1 alternate;' +
'animation: some_animation 2s linear 0s 1 alternate;' ;
2013-10-07 18:35:24 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.ng-hide-add' , style ) ;
ss . addRule ( '.ng-hide-remove' , style ) ;
2013-10-25 18:20:35 +00:00
2013-11-25 18:40:52 +00:00
element = $compile ( html ( '<div class="ng-hide">1</div>' ) ) ( $rootScope ) ;
element . addClass ( 'custom' ) ;
2013-10-25 18:20:35 +00:00
2013-11-25 18:40:52 +00:00
$animate . removeClass ( element , 'ng-hide' ) ;
2013-10-25 18:20:35 +00:00
2013-11-25 18:40:52 +00:00
if ( $sniffer . animations ) {
$timeout . flush ( ) ;
expect ( element . hasClass ( 'ng-hide-remove' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'ng-hide-remove-active' ) ) . toBe ( true ) ;
}
2013-10-25 18:20:35 +00:00
2013-11-25 18:40:52 +00:00
element . removeClass ( 'ng-hide' ) ;
$animate . addClass ( element , 'ng-hide' ) ;
expect ( element . hasClass ( 'ng-hide-remove' ) ) . toBe ( false ) ; //added right away
2013-10-25 18:20:35 +00:00
2013-11-25 18:40:52 +00:00
if ( $sniffer . animations ) { //cleanup some pending animations
$timeout . flush ( ) ;
expect ( element . hasClass ( 'ng-hide-add' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'ng-hide-add-active' ) ) . toBe ( true ) ;
browserTrigger ( element , 'animationend' , { timeStamp : Date . now ( ) + 2000 , elapsedTime : 2 } ) ;
}
2013-10-25 18:20:35 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . hasClass ( 'ng-hide-remove-active' ) ) . toBe ( false ) ;
} ) ) ;
2013-10-25 18:20:35 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should stagger the items when the correct CSS class is provided" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $timeout , $document , $rootElement ) {
2013-10-25 18:20:35 +00:00
2013-11-25 18:40:52 +00:00
if ( ! $sniffer . animations ) return ;
2013-10-25 18:20:35 +00:00
2013-11-25 18:40:52 +00:00
$animate . enabled ( true ) ;
2013-10-25 18:20:35 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.real-animation.ng-enter, .real-animation.ng-leave, .real-animation-fake.ng-enter, .real-animation-fake.ng-leave' ,
'-webkit-animation:1s my_animation;' +
'animation:1s my_animation;' ) ;
ss . addRule ( '.real-animation.ng-enter-stagger, .real-animation.ng-leave-stagger' ,
'-webkit-animation-delay:0.1s;' +
'-webkit-animation-duration:0s;' +
'animation-delay:0.1s;' +
'animation-duration:0s;' ) ;
ss . addRule ( '.fake-animation.ng-enter-stagger, .fake-animation.ng-leave-stagger' ,
'-webkit-animation-delay:0.1s;' +
'-webkit-animation-duration:1s;' +
'animation-delay:0.1s;' +
'animation-duration:1s;' ) ;
var container = $compile ( html ( '<div></div>' ) ) ( $rootScope ) ;
var elements = [ ] ;
for ( var i = 0 ; i < 5 ; i ++ ) {
var newScope = $rootScope . $new ( ) ;
var element = $compile ( '<div class="real-animation"></div>' ) ( newScope ) ;
$animate . enter ( element , container ) ;
elements . push ( element ) ;
} ;
$rootScope . $digest ( ) ;
$timeout . flush ( ) ;
expect ( elements [ 0 ] . attr ( 'style' ) ) . toBeFalsy ( ) ;
expect ( elements [ 1 ] . attr ( 'style' ) ) . toMatch ( /animation-delay: 0\.1\d*s/ ) ;
expect ( elements [ 2 ] . attr ( 'style' ) ) . toMatch ( /animation-delay: 0\.2\d*s/ ) ;
expect ( elements [ 3 ] . attr ( 'style' ) ) . toMatch ( /animation-delay: 0\.3\d*s/ ) ;
expect ( elements [ 4 ] . attr ( 'style' ) ) . toMatch ( /animation-delay: 0\.4\d*s/ ) ;
for ( var i = 0 ; i < 5 ; i ++ ) {
dealoc ( elements [ i ] ) ;
var newScope = $rootScope . $new ( ) ;
var element = $compile ( '<div class="fake-animation"></div>' ) ( newScope ) ;
$animate . enter ( element , container ) ;
elements [ i ] = element ;
} ;
$rootScope . $digest ( ) ;
$timeout . flush ( ) ;
expect ( elements [ 0 ] . attr ( 'style' ) ) . toBeFalsy ( ) ;
expect ( elements [ 1 ] . attr ( 'style' ) ) . not . toMatch ( /animation-delay: 0\.1\d*s/ ) ;
expect ( elements [ 2 ] . attr ( 'style' ) ) . not . toMatch ( /animation-delay: 0\.2\d*s/ ) ;
expect ( elements [ 3 ] . attr ( 'style' ) ) . not . toMatch ( /animation-delay: 0\.3\d*s/ ) ;
expect ( elements [ 4 ] . attr ( 'style' ) ) . not . toMatch ( /animation-delay: 0\.4\d*s/ ) ;
} ) ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should stagger items when multiple animation durations/delays are defined" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $timeout , $document , $rootElement ) {
if ( ! $sniffer . transitions ) return ;
$animate . enabled ( true ) ;
ss . addRule ( '.stagger-animation.ng-enter, .stagger-animation.ng-leave' ,
'-webkit-animation:my_animation 1s 1s, your_animation 1s 2s;' +
'animation:my_animation 1s 1s, your_animation 1s 2s;' ) ;
ss . addRule ( '.stagger-animation.ng-enter-stagger, .stagger-animation.ng-leave-stagger' ,
'-webkit-animation-delay:0.1s;' +
'animation-delay:0.1s;' ) ;
var container = $compile ( html ( '<div></div>' ) ) ( $rootScope ) ;
var elements = [ ] ;
for ( var i = 0 ; i < 4 ; i ++ ) {
var newScope = $rootScope . $new ( ) ;
var element = $compile ( '<div class="stagger-animation"></div>' ) ( newScope ) ;
$animate . enter ( element , container ) ;
elements . push ( element ) ;
} ;
$rootScope . $digest ( ) ;
$timeout . flush ( ) ;
expect ( elements [ 0 ] . attr ( 'style' ) ) . toBeFalsy ( ) ;
expect ( elements [ 1 ] . attr ( 'style' ) ) . toMatch ( /animation-delay: 1\.1\d*s,\s*2\.1\d*s/ ) ;
expect ( elements [ 2 ] . attr ( 'style' ) ) . toMatch ( /animation-delay: 1\.2\d*s,\s*2\.2\d*s/ ) ;
expect ( elements [ 3 ] . attr ( 'style' ) ) . toMatch ( /animation-delay: 1\.3\d*s,\s*2\.3\d*s/ ) ;
} ) ) ;
2013-12-14 05:30:48 +00:00
2013-11-25 18:40:52 +00:00
} ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
describe ( "Transitions" , function ( ) {
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should skip transitions if disabled and run when enabled" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $timeout ) {
var style = '-webkit-transition: 1s linear all;' +
'transition: 1s linear all;' ;
ss . addRule ( '.ng-hide-add' , style ) ;
ss . addRule ( '.ng-hide-remove' , style ) ;
$animate . enabled ( false ) ;
element = $compile ( html ( '<div>1</div>' ) ) ( $rootScope ) ;
element . addClass ( 'ng-hide' ) ;
expect ( element ) . toBeHidden ( ) ;
$animate . removeClass ( element , 'ng-hide' ) ;
expect ( element ) . toBeShown ( ) ;
$animate . enabled ( true ) ;
element . addClass ( 'ng-hide' ) ;
expect ( element ) . toBeHidden ( ) ;
$animate . removeClass ( element , 'ng-hide' ) ;
if ( $sniffer . transitions ) {
$timeout . flush ( ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
}
expect ( element ) . toBeShown ( ) ;
} ) ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should skip animations if disabled and run when enabled picking the longest specified duration" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $timeout ) {
var style = '-webkit-transition-duration: 1s, 2000ms, 1s;' +
'-webkit-transition-property: height, left, opacity;' +
'transition-duration: 1s, 2000ms, 1s;' +
'transition-property: height, left, opacity;' ;
2013-10-25 18:20:35 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.ng-hide-add' , style ) ;
ss . addRule ( '.ng-hide-remove' , style ) ;
2013-10-25 18:20:35 +00:00
2013-11-25 18:40:52 +00:00
element = $compile ( html ( '<div>foo</div>' ) ) ( $rootScope ) ;
element . addClass ( 'ng-hide' ) ;
2013-10-31 18:49:06 +00:00
2013-11-25 18:40:52 +00:00
$animate . removeClass ( element , 'ng-hide' ) ;
2013-10-31 18:49:06 +00:00
2013-11-25 18:40:52 +00:00
if ( $sniffer . transitions ) {
$timeout . flush ( ) ;
var now = Date . now ( ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : now + 1000 , elapsedTime : 1 } ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : now + 1000 , elapsedTime : 1 } ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : now + 2000 , elapsedTime : 2 } ) ;
expect ( element . hasClass ( 'ng-animate' ) ) . toBe ( false ) ;
}
expect ( element ) . toBeShown ( ) ;
} ) ) ;
2013-10-31 18:49:06 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should skip animations if disabled and run when enabled picking the longest specified duration/delay combination" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $timeout ) {
$animate . enabled ( false ) ;
var style = '-webkit-transition-duration: 1s, 0s, 1s; ' +
'-webkit-transition-delay: 2s, 1000ms, 2s; ' +
'-webkit-transition-property: height, left, opacity;' +
'transition-duration: 1s, 0s, 1s; ' +
'transition-delay: 2s, 1000ms, 2s; ' +
'transition-property: height, left, opacity;' ;
ss . addRule ( '.ng-hide-add' , style ) ;
ss . addRule ( '.ng-hide-remove' , style ) ;
element = $compile ( html ( '<div>foo</div>' ) ) ( $rootScope ) ;
element . addClass ( 'ng-hide' ) ;
$animate . removeClass ( element , 'ng-hide' ) ;
$timeout . flush ( 0 ) ;
expect ( element ) . toBeShown ( ) ;
$animate . enabled ( true ) ;
element . addClass ( 'ng-hide' ) ;
expect ( element ) . toBeHidden ( ) ;
$animate . removeClass ( element , 'ng-hide' ) ;
if ( $sniffer . transitions ) {
$timeout . flush ( ) ;
var now = Date . now ( ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : now + 1000 , elapsedTime : 1 } ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : now + 3000 , elapsedTime : 3 } ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : now + 3000 , elapsedTime : 3 } ) ;
}
expect ( element ) . toBeShown ( ) ;
} ) ) ;
2013-10-31 18:49:06 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should NOT overwrite styles with outdated values when animation completes" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $timeout ) {
2013-10-31 18:49:06 +00:00
2013-11-25 18:40:52 +00:00
if ( ! $sniffer . transitions ) return ;
2013-10-31 18:49:06 +00:00
2013-11-25 18:40:52 +00:00
var style = '-webkit-transition-duration: 1s, 2000ms, 1s;' +
'-webkit-transition-property: height, left, opacity;' +
'transition-duration: 1s, 2000ms, 1s;' +
'transition-property: height, left, opacity;' ;
2013-10-31 18:49:06 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.ng-hide-add' , style ) ;
ss . addRule ( '.ng-hide-remove' , style ) ;
2013-10-31 18:49:06 +00:00
2013-11-25 18:40:52 +00:00
element = $compile ( html ( '<div style="width: 100px">foo</div>' ) ) ( $rootScope ) ;
element . addClass ( 'ng-hide' ) ;
2013-10-31 18:49:06 +00:00
2013-11-25 18:40:52 +00:00
$animate . removeClass ( element , 'ng-hide' ) ;
2013-10-31 18:49:06 +00:00
2013-11-25 18:40:52 +00:00
$timeout . flush ( ) ;
2013-10-31 18:49:06 +00:00
2013-11-25 18:40:52 +00:00
var now = Date . now ( ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : now + 1000 , elapsedTime : 1 } ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : now + 1000 , elapsedTime : 1 } ) ;
2013-10-31 18:49:06 +00:00
2013-11-25 18:40:52 +00:00
element . css ( 'width' , '200px' ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : now + 2000 , elapsedTime : 2 } ) ;
expect ( element . css ( 'width' ) ) . toBe ( "200px" ) ;
} ) ) ;
2013-10-31 18:49:06 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should animate for the highest duration" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $timeout ) {
var style = '-webkit-transition:1s linear all 2s;' +
'transition:1s linear all 2s;' +
'-webkit-animation:my_ani 10s 1s;' +
'animation:my_ani 10s 1s;' ;
2013-10-31 18:49:06 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.ng-hide-add' , style ) ;
ss . addRule ( '.ng-hide-remove' , style ) ;
2013-10-31 18:49:06 +00:00
2013-11-25 18:40:52 +00:00
element = $compile ( html ( '<div>foo</div>' ) ) ( $rootScope ) ;
2013-10-31 18:49:06 +00:00
2013-11-25 18:40:52 +00:00
element . addClass ( 'ng-hide' ) ;
expect ( element ) . toBeHidden ( ) ;
2013-10-31 18:49:06 +00:00
2013-11-25 18:40:52 +00:00
$animate . removeClass ( element , 'ng-hide' ) ;
if ( $sniffer . transitions ) {
$timeout . flush ( ) ;
}
expect ( element ) . toBeShown ( ) ;
if ( $sniffer . transitions ) {
2013-12-14 05:30:48 +00:00
expect ( element . hasClass ( 'ng-hide-remove-active' ) ) . toBe ( true ) ;
2013-11-25 18:40:52 +00:00
browserTrigger ( element , 'animationend' , { timeStamp : Date . now ( ) + 11000 , elapsedTime : 11 } ) ;
2013-12-14 05:30:48 +00:00
expect ( element . hasClass ( 'ng-hide-remove-active' ) ) . toBe ( false ) ;
2013-11-25 18:40:52 +00:00
}
} ) ) ;
2013-10-31 18:49:06 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should finish the previous transition when a new animation is started" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $timeout ) {
var style = '-webkit-transition: 1s linear all;' +
'transition: 1s linear all;' ;
2013-10-31 18:49:06 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.ng-hide-add' , style ) ;
ss . addRule ( '.ng-hide-remove' , style ) ;
2013-10-31 18:49:06 +00:00
2013-11-25 18:40:52 +00:00
element = $compile ( html ( '<div>1</div>' ) ) ( $rootScope ) ;
2013-10-31 18:49:06 +00:00
2013-11-25 18:40:52 +00:00
element . addClass ( 'ng-hide' ) ;
$animate . removeClass ( element , 'ng-hide' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
if ( $sniffer . transitions ) {
$timeout . flush ( ) ;
expect ( element . hasClass ( 'ng-hide-remove' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'ng-hide-remove-active' ) ) . toBe ( true ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
}
expect ( element . hasClass ( 'ng-hide-remove' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'ng-hide-remove-active' ) ) . toBe ( false ) ;
expect ( element ) . toBeShown ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( element , 'ng-hide' ) ;
2013-08-21 19:03:41 +00:00
2013-11-25 18:40:52 +00:00
if ( $sniffer . transitions ) {
$timeout . flush ( ) ;
expect ( element . hasClass ( 'ng-hide-add' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'ng-hide-add-active' ) ) . toBe ( true ) ;
}
} ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should stagger the items when the correct CSS class is provided" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $timeout , $document , $rootElement ) {
2013-07-22 19:37:45 +00:00
2013-11-25 18:40:52 +00:00
if ( ! $sniffer . transitions ) return ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$animate . enabled ( true ) ;
2013-07-22 19:37:45 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.real-animation.ng-enter, .real-animation.ng-leave, .real-animation-fake.ng-enter, .real-animation-fake.ng-leave' ,
'-webkit-transition:1s linear all;' +
'transition:1s linear all;' ) ;
ss . addRule ( '.real-animation.ng-enter-stagger, .real-animation.ng-leave-stagger' ,
'-webkit-transition-delay:0.1s;' +
'-webkit-transition-duration:0s;' +
'transition-delay:0.1s;' +
'transition-duration:0s;' ) ;
ss . addRule ( '.fake-animation.ng-enter-stagger, .fake-animation.ng-leave-stagger' ,
'-webkit-transition-delay:0.1s;' +
'-webkit-transition-duration:1s;' +
'transition-delay:0.1s;' +
'transition-duration:1s;' ) ;
var container = $compile ( html ( '<div></div>' ) ) ( $rootScope ) ;
var elements = [ ] ;
for ( var i = 0 ; i < 5 ; i ++ ) {
var newScope = $rootScope . $new ( ) ;
var element = $compile ( '<div class="real-animation"></div>' ) ( newScope ) ;
$animate . enter ( element , container ) ;
elements . push ( element ) ;
} ;
$rootScope . $digest ( ) ;
$timeout . flush ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( elements [ 0 ] . attr ( 'style' ) ) . toBeFalsy ( ) ;
expect ( elements [ 1 ] . attr ( 'style' ) ) . toMatch ( /transition-delay: 0\.1\d*s/ ) ;
expect ( elements [ 2 ] . attr ( 'style' ) ) . toMatch ( /transition-delay: 0\.2\d*s/ ) ;
expect ( elements [ 3 ] . attr ( 'style' ) ) . toMatch ( /transition-delay: 0\.3\d*s/ ) ;
expect ( elements [ 4 ] . attr ( 'style' ) ) . toMatch ( /transition-delay: 0\.4\d*s/ ) ;
for ( var i = 0 ; i < 5 ; i ++ ) {
dealoc ( elements [ i ] ) ;
var newScope = $rootScope . $new ( ) ;
var element = $compile ( '<div class="fake-animation"></div>' ) ( newScope ) ;
$animate . enter ( element , container ) ;
elements [ i ] = element ;
} ;
$rootScope . $digest ( ) ;
$timeout . flush ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( elements [ 0 ] . attr ( 'style' ) ) . toBeFalsy ( ) ;
expect ( elements [ 1 ] . attr ( 'style' ) ) . not . toMatch ( /transition-delay: 0\.1\d*s/ ) ;
expect ( elements [ 2 ] . attr ( 'style' ) ) . not . toMatch ( /transition-delay: 0\.2\d*s/ ) ;
expect ( elements [ 3 ] . attr ( 'style' ) ) . not . toMatch ( /transition-delay: 0\.3\d*s/ ) ;
expect ( elements [ 4 ] . attr ( 'style' ) ) . not . toMatch ( /transition-delay: 0\.4\d*s/ ) ;
} ) ) ;
2013-08-21 19:03:41 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should stagger items when multiple transition durations/delays are defined" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $timeout , $document , $rootElement ) {
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
if ( ! $sniffer . transitions ) return ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$animate . enabled ( true ) ;
2013-10-07 18:35:24 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.stagger-animation.ng-enter, .ani.ng-leave' ,
'-webkit-transition:1s linear color 2s, 3s linear font-size 4s;' +
'transition:1s linear color 2s, 3s linear font-size 4s;' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.stagger-animation.ng-enter-stagger, .ani.ng-leave-stagger' ,
'-webkit-transition-delay:0.1s;' +
'transition-delay:0.1s;' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var container = $compile ( html ( '<div></div>' ) ) ( $rootScope ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var elements = [ ] ;
for ( var i = 0 ; i < 4 ; i ++ ) {
var newScope = $rootScope . $new ( ) ;
var element = $compile ( '<div class="stagger-animation"></div>' ) ( newScope ) ;
$animate . enter ( element , container ) ;
elements . push ( element ) ;
} ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$rootScope . $digest ( ) ;
$timeout . flush ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( elements [ 0 ] . attr ( 'style' ) ) . not . toContain ( 'transition-delay' ) ;
expect ( elements [ 1 ] . attr ( 'style' ) ) . toMatch ( /transition-delay: 2\.1\d*s,\s*4\.1\d*s/ ) ;
expect ( elements [ 2 ] . attr ( 'style' ) ) . toMatch ( /transition-delay: 2\.2\d*s,\s*4\.2\d*s/ ) ;
expect ( elements [ 3 ] . attr ( 'style' ) ) . toMatch ( /transition-delay: 2\.3\d*s,\s*4\.3\d*s/ ) ;
} ) ) ;
2013-12-14 05:30:48 +00:00
2013-12-19 16:56:26 +00:00
2013-12-14 05:30:48 +00:00
it ( "apply a closing timeout to close all pending transitions" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $timeout ) {
if ( ! $sniffer . transitions ) return ;
ss . addRule ( '.animated-element' , '-webkit-transition:5s linear all;' +
'transition:5s linear all;' ) ;
element = $compile ( html ( '<div class="animated-element">foo</div>' ) ) ( $rootScope ) ;
$animate . addClass ( element , 'some-class' ) ;
$timeout . flush ( 10 ) ; //reflow
expect ( element . hasClass ( 'some-class-add-active' ) ) . toBe ( true ) ;
$timeout . flush ( 7500 ) ; //closing timeout
expect ( element . hasClass ( 'some-class-add-active' ) ) . toBe ( false ) ;
} ) ) ;
2013-12-19 16:56:26 +00:00
2013-12-14 05:30:48 +00:00
it ( "should not allow the closing animation to close off a successive animation midway" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $timeout ) {
if ( ! $sniffer . transitions ) return ;
ss . addRule ( '.some-class-add' , '-webkit-transition:5s linear all;' +
'transition:5s linear all;' ) ;
ss . addRule ( '.some-class-remove' , '-webkit-transition:10s linear all;' +
'transition:10s linear all;' ) ;
element = $compile ( html ( '<div>foo</div>' ) ) ( $rootScope ) ;
$animate . addClass ( element , 'some-class' ) ;
$timeout . flush ( 10 ) ; //reflow
expect ( element . hasClass ( 'some-class-add-active' ) ) . toBe ( true ) ;
$animate . removeClass ( element , 'some-class' ) ;
$timeout . flush ( 10 ) ; //second reflow
$timeout . flush ( 7500 ) ; //closing timeout for the first animation
expect ( element . hasClass ( 'some-class-remove-active' ) ) . toBe ( true ) ;
$timeout . flush ( 15000 ) ; //closing timeout for the second animation
expect ( element . hasClass ( 'some-class-remove-active' ) ) . toBe ( false ) ;
$timeout . verifyNoPendingTasks ( ) ;
} ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
} ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should apply staggering to both transitions and keyframe animations when used within the same animation" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $timeout , $document , $rootElement ) {
2013-08-21 19:03:41 +00:00
2013-11-25 18:40:52 +00:00
if ( ! $sniffer . transitions ) return ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$animate . enabled ( true ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.stagger-animation.ng-enter, .stagger-animation.ng-leave' ,
'-webkit-animation:my_animation 1s 1s, your_animation 1s 2s;' +
'animation:my_animation 1s 1s, your_animation 1s 2s;' +
'-webkit-transition:1s linear all 1s;' +
'transition:1s linear all 1s;' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.stagger-animation.ng-enter-stagger, .stagger-animation.ng-leave-stagger' ,
'-webkit-transition-delay:0.1s;' +
'transition-delay:0.1s;' +
'-webkit-animation-delay:0.2s;' +
'animation-delay:0.2s;' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var container = $compile ( html ( '<div></div>' ) ) ( $rootScope ) ;
2013-08-28 23:18:33 +00:00
2013-11-25 18:40:52 +00:00
var elements = [ ] ;
for ( var i = 0 ; i < 3 ; i ++ ) {
var newScope = $rootScope . $new ( ) ;
var element = $compile ( '<div class="stagger-animation"></div>' ) ( newScope ) ;
$animate . enter ( element , container ) ;
elements . push ( element ) ;
} ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$rootScope . $digest ( ) ;
$timeout . flush ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( elements [ 0 ] . attr ( 'style' ) ) . toBeFalsy ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( elements [ 1 ] . attr ( 'style' ) ) . toMatch ( /transition-delay:\s+1.1\d*/ ) ;
expect ( elements [ 1 ] . attr ( 'style' ) ) . toMatch ( /animation-delay: 1\.2\d*s,\s*2\.2\d*s/ ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( elements [ 2 ] . attr ( 'style' ) ) . toMatch ( /transition-delay:\s+1.2\d*/ ) ;
expect ( elements [ 2 ] . attr ( 'style' ) ) . toMatch ( /animation-delay: 1\.4\d*s,\s*2\.4\d*s/ ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
for ( var i = 0 ; i < 3 ; i ++ ) {
browserTrigger ( elements [ i ] , 'transitionend' , { timeStamp : Date . now ( ) + 22000 , elapsedTime : 22000 } ) ;
expect ( elements [ i ] . attr ( 'style' ) ) . toBeFalsy ( ) ;
}
} ) ) ;
} ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
describe ( 'animation evaluation' , function ( ) {
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( 'should re-evaluate the CSS classes for an animation each time' ,
inject ( function ( $animate , $rootScope , $sniffer , $rootElement , $timeout , $compile ) {
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.abc.ng-enter' , '-webkit-transition:22s linear all;' +
'transition:22s linear all;' ) ;
ss . addRule ( '.xyz.ng-enter' , '-webkit-transition:11s linear all;' +
'transition:11s linear all;' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var parent = $compile ( '<div><span ng-class="klass"></span></div>' ) ( $rootScope ) ;
var element = parent . find ( 'span' ) ;
$rootElement . append ( parent ) ;
angular . element ( document . body ) . append ( $rootElement ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$rootScope . klass = 'abc' ;
$animate . enter ( element , parent ) ;
$rootScope . $digest ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
if ( $sniffer . transitions ) {
$timeout . flush ( ) ;
expect ( element . hasClass ( 'abc' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'ng-enter' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'ng-enter-active' ) ) . toBe ( true ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : Date . now ( ) + 22000 , elapsedTime : 22 } ) ;
$timeout . flush ( ) ;
}
expect ( element . hasClass ( 'abc' ) ) . toBe ( true ) ;
2013-08-28 23:18:33 +00:00
2013-11-25 18:40:52 +00:00
$rootScope . klass = 'xyz' ;
$animate . enter ( element , parent ) ;
$rootScope . $digest ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
if ( $sniffer . transitions ) {
$timeout . flush ( ) ;
expect ( element . hasClass ( 'xyz' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'ng-enter' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'ng-enter-active' ) ) . toBe ( true ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : Date . now ( ) + 11000 , elapsedTime : 11 } ) ;
$timeout . flush ( ) ;
}
expect ( element . hasClass ( 'xyz' ) ) . toBe ( true ) ;
} ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( 'should only append active to the newly append CSS className values' ,
inject ( function ( $animate , $rootScope , $sniffer , $rootElement , $timeout ) {
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.ng-enter' , '-webkit-transition:9s linear all;' +
'transition:9s linear all;' ) ;
ss . addRule ( '.ng-enter' , '-webkit-transition:9s linear all;' +
'transition:9s linear all;' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var parent = jqLite ( '<div><span></span></div>' ) ;
var element = parent . find ( 'span' ) ;
$rootElement . append ( parent ) ;
angular . element ( document . body ) . append ( $rootElement ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
element . attr ( 'class' , 'one two' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$animate . enter ( element , parent ) ;
$rootScope . $digest ( ) ;
2013-08-21 19:03:41 +00:00
2013-11-25 18:40:52 +00:00
if ( $sniffer . transitions ) {
$timeout . flush ( ) ;
expect ( element . hasClass ( 'one' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'two' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'ng-enter' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'ng-enter-active' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'one-active' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'two-active' ) ) . toBe ( false ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : Date . now ( ) + 3000 , elapsedTime : 3 } ) ;
}
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . hasClass ( 'one' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'two' ) ) . toBe ( true ) ;
} ) ) ;
} ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
describe ( "Callbacks" , function ( ) {
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
beforeEach ( function ( ) {
module ( function ( $animateProvider ) {
$animateProvider . register ( '.custom' , function ( $timeout ) {
return {
removeClass : function ( element , className , done ) {
$timeout ( done , 2000 ) ;
}
}
} ) ;
$animateProvider . register ( '.other' , function ( ) {
return {
enter : function ( element , done ) {
$timeout ( done , 10000 ) ;
}
}
} ) ;
} )
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
} ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should fire the enter callback" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $rootElement , $timeout ) {
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var parent = jqLite ( '<div><span></span></div>' ) ;
var element = parent . find ( 'span' ) ;
$rootElement . append ( parent ) ;
body . append ( $rootElement ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var flag = false ;
$animate . enter ( element , parent , null , function ( ) {
flag = true ;
} ) ;
$rootScope . $digest ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$timeout . flush ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( flag ) . toBe ( true ) ;
} ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should fire the leave callback" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $rootElement , $timeout ) {
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var parent = jqLite ( '<div><span></span></div>' ) ;
var element = parent . find ( 'span' ) ;
$rootElement . append ( parent ) ;
body . append ( $rootElement ) ;
2013-08-21 19:03:41 +00:00
2013-11-25 18:40:52 +00:00
var flag = false ;
$animate . leave ( element , function ( ) {
flag = true ;
} ) ;
$rootScope . $digest ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$timeout . flush ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( flag ) . toBe ( true ) ;
} ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should fire the move callback" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $rootElement , $timeout ) {
var parent = jqLite ( '<div><span></span></div>' ) ;
var parent2 = jqLite ( '<div id="nice"></div>' ) ;
var element = parent . find ( 'span' ) ;
$rootElement . append ( parent ) ;
body . append ( $rootElement ) ;
var flag = false ;
$animate . move ( element , parent , parent2 , function ( ) {
flag = true ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
} ) ;
2013-11-25 18:40:52 +00:00
$rootScope . $digest ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$timeout . flush ( ) ;
2013-10-23 19:14:27 +00:00
2013-11-25 18:40:52 +00:00
expect ( flag ) . toBe ( true ) ;
expect ( element . parent ( ) . id ) . toBe ( parent2 . id ) ;
} ) ) ;
2013-10-23 19:14:27 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should fire the addClass/removeClass callbacks" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $rootElement , $timeout ) {
2013-10-23 19:14:27 +00:00
2013-11-25 18:40:52 +00:00
var parent = jqLite ( '<div><span></span></div>' ) ;
var element = parent . find ( 'span' ) ;
$rootElement . append ( parent ) ;
body . append ( $rootElement ) ;
2013-10-23 19:14:27 +00:00
2013-11-25 18:40:52 +00:00
var signature = '' ;
$animate . addClass ( element , 'on' , function ( ) {
signature += 'A' ;
} ) ;
2013-10-23 19:14:27 +00:00
2013-11-25 18:40:52 +00:00
$animate . removeClass ( element , 'on' , function ( ) {
signature += 'B' ;
} ) ;
2013-10-23 19:14:27 +00:00
2013-11-25 18:40:52 +00:00
$timeout . flush ( ) ;
2013-10-23 19:14:27 +00:00
2013-11-25 18:40:52 +00:00
expect ( signature ) . toBe ( 'AB' ) ;
} ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should fire a done callback when provided with no animation" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $rootElement , $timeout ) {
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var parent = jqLite ( '<div><span></span></div>' ) ;
var element = parent . find ( 'span' ) ;
$rootElement . append ( parent ) ;
body . append ( $rootElement ) ;
2013-07-22 19:37:45 +00:00
2013-11-25 18:40:52 +00:00
var flag = false ;
$animate . removeClass ( element , 'ng-hide' , function ( ) {
flag = true ;
} ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$timeout . flush ( ) ;
expect ( flag ) . toBe ( true ) ;
} ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should fire a done callback when provided with a css animation/transition" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $rootElement , $timeout ) {
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.ng-hide-add' , '-webkit-transition:1s linear all;' +
'transition:1s linear all;' ) ;
ss . addRule ( '.ng-hide-remove' , '-webkit-transition:1s linear all;' +
'transition:1s linear all;' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var parent = jqLite ( '<div><span></span></div>' ) ;
$rootElement . append ( parent ) ;
body . append ( $rootElement ) ;
var element = parent . find ( 'span' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var flag = false ;
$animate . removeClass ( element , 'ng-hide' , function ( ) {
flag = true ;
} ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
if ( $sniffer . transitions ) {
browserTrigger ( element , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
}
$timeout . flush ( ) ;
expect ( flag ) . toBe ( true ) ;
} ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should fire a done callback when provided with a JS animation" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $rootElement , $timeout ) {
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var parent = jqLite ( '<div><span></span></div>' ) ;
$rootElement . append ( parent ) ;
body . append ( $rootElement ) ;
var element = parent . find ( 'span' ) ;
element . addClass ( 'custom' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var flag = false ;
$animate . removeClass ( element , 'ng-hide' , function ( ) {
flag = true ;
} ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$timeout . flush ( ) ;
expect ( flag ) . toBe ( true ) ;
} ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should fire the callback right away if another animation is called right after" ,
inject ( function ( $animate , $rootScope , $compile , $sniffer , $rootElement , $timeout ) {
2013-08-21 19:03:41 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.ng-hide-add' , '-webkit-transition:9s linear all;' +
'transition:9s linear all;' ) ;
ss . addRule ( '.ng-hide-remove' , '-webkit-transition:9s linear all;' +
'transition:9s linear all;' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var parent = jqLite ( '<div><span></span></div>' ) ;
$rootElement . append ( parent ) ;
body . append ( $rootElement ) ;
var element = parent . find ( 'span' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var signature = '' ;
$animate . removeClass ( element , 'ng-hide' , function ( ) {
signature += 'A' ;
} ) ;
$animate . addClass ( element , 'ng-hide' , function ( ) {
signature += 'B' ;
} ) ;
2013-10-07 18:35:24 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( element , 'ng-hide' ) ; //earlier animation cancelled
2013-11-04 21:23:56 +00:00
$timeout . flush ( ) ;
2013-11-25 18:40:52 +00:00
expect ( signature ) . toBe ( 'AB' ) ;
} ) ) ;
} ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
describe ( "addClass / removeClass" , function ( ) {
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
var captured ;
beforeEach ( function ( ) {
module ( function ( $animateProvider , $provide ) {
$animateProvider . register ( '.klassy' , function ( $timeout ) {
return {
addClass : function ( element , className , done ) {
captured = 'addClass-' + className ;
$timeout ( done , 500 , false ) ;
} ,
removeClass : function ( element , className , done ) {
captured = 'removeClass-' + className ;
$timeout ( done , 3000 , false ) ;
}
}
} ) ;
} ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
} ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should not perform an animation, and the followup DOM operation, if the class is " +
"already present during addClass or not present during removeClass on the element" ,
inject ( function ( $animate , $rootScope , $sniffer , $rootElement , $timeout ) {
2013-11-04 21:23:56 +00:00
2013-11-25 18:40:52 +00:00
var element = jqLite ( '<div class="klassy"></div>' ) ;
$rootElement . append ( element ) ;
body . append ( $rootElement ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
//skipped animations
captured = 'none' ;
$animate . removeClass ( element , 'some-class' ) ;
expect ( element . hasClass ( 'some-class' ) ) . toBe ( false ) ;
expect ( captured ) . toBe ( 'none' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
element . addClass ( 'some-class' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
captured = 'nothing' ;
$animate . addClass ( element , 'some-class' ) ;
expect ( captured ) . toBe ( 'nothing' ) ;
expect ( element . hasClass ( 'some-class' ) ) . toBe ( true ) ;
2013-07-22 19:37:45 +00:00
2013-11-25 18:40:52 +00:00
//actual animations
captured = 'none' ;
$animate . removeClass ( element , 'some-class' ) ;
$timeout . flush ( ) ;
expect ( element . hasClass ( 'some-class' ) ) . toBe ( false ) ;
expect ( captured ) . toBe ( 'removeClass-some-class' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
captured = 'nothing' ;
$animate . addClass ( element , 'some-class' ) ;
$timeout . flush ( ) ;
expect ( element . hasClass ( 'some-class' ) ) . toBe ( true ) ;
expect ( captured ) . toBe ( 'addClass-some-class' ) ;
} ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should add and remove CSS classes after an animation even if no animation is present" ,
inject ( function ( $animate , $rootScope , $sniffer , $rootElement ) {
2013-08-21 19:03:41 +00:00
2013-11-25 18:40:52 +00:00
var parent = jqLite ( '<div><span></span></div>' ) ;
$rootElement . append ( parent ) ;
body . append ( $rootElement ) ;
var element = jqLite ( parent . find ( 'span' ) ) ;
2013-07-22 19:37:45 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( element , 'klass' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . hasClass ( 'klass' ) ) . toBe ( true ) ;
2013-08-21 19:03:41 +00:00
2013-11-25 18:40:52 +00:00
$animate . removeClass ( element , 'klass' ) ;
2013-07-22 19:37:45 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . hasClass ( 'klass' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'klass-remove' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'klass-remove-active' ) ) . toBe ( false ) ;
} ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should add and remove CSS classes with a callback" ,
inject ( function ( $animate , $rootScope , $sniffer , $rootElement , $timeout ) {
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var parent = jqLite ( '<div><span></span></div>' ) ;
$rootElement . append ( parent ) ;
body . append ( $rootElement ) ;
var element = jqLite ( parent . find ( 'span' ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var signature = '' ;
2013-08-22 01:29:40 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( element , 'klass' , function ( ) {
signature += 'A' ;
} ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . hasClass ( 'klass' ) ) . toBe ( true ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$animate . removeClass ( element , 'klass' , function ( ) {
signature += 'B' ;
} ) ;
2013-10-07 18:35:24 +00:00
$timeout . flush ( ) ;
2013-11-25 18:40:52 +00:00
expect ( element . hasClass ( 'klass' ) ) . toBe ( false ) ;
expect ( signature ) . toBe ( 'AB' ) ;
} ) ) ;
2013-07-22 19:37:45 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should end the current addClass animation, add the CSS class and then run the removeClass animation" ,
inject ( function ( $animate , $rootScope , $sniffer , $rootElement , $timeout ) {
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.klass-add' , '-webkit-transition:3s linear all;' +
'transition:3s linear all;' ) ;
ss . addRule ( '.klass-remove' , '-webkit-transition:3s linear all;' +
'transition:3s linear all;' ) ;
2013-10-07 18:35:24 +00:00
2013-11-25 18:40:52 +00:00
var parent = jqLite ( '<div><span></span></div>' ) ;
$rootElement . append ( parent ) ;
body . append ( $rootElement ) ;
var element = jqLite ( parent . find ( 'span' ) ) ;
2013-07-22 19:37:45 +00:00
2013-11-25 18:40:52 +00:00
var signature = '' ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( element , 'klass' , function ( ) {
signature += '1' ;
} ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
if ( $sniffer . transitions ) {
expect ( element . hasClass ( 'klass-add' ) ) . toBe ( true ) ;
$timeout . flush ( ) ;
expect ( element . hasClass ( 'klass' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'klass-add-active' ) ) . toBe ( true ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : Date . now ( ) + 3000 , elapsedTime : 3 } ) ;
}
$timeout . flush ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
//this cancels out the older animation
$animate . removeClass ( element , 'klass' , function ( ) {
signature += '2' ;
} ) ;
2013-08-21 19:03:41 +00:00
2013-11-25 18:40:52 +00:00
if ( $sniffer . transitions ) {
expect ( element . hasClass ( 'klass-remove' ) ) . toBe ( true ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$timeout . flush ( ) ;
expect ( element . hasClass ( 'klass' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'klass-add' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'klass-add-active' ) ) . toBe ( false ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
browserTrigger ( element , 'transitionend' , { timeStamp : Date . now ( ) + 3000 , elapsedTime : 3 } ) ;
}
2013-10-07 18:35:24 +00:00
$timeout . flush ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . hasClass ( 'klass' ) ) . toBe ( false ) ;
expect ( signature ) . toBe ( '12' ) ;
} ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should properly execute JS animations and use callbacks when using addClass / removeClass" ,
inject ( function ( $animate , $rootScope , $sniffer , $rootElement , $timeout ) {
2013-08-28 23:18:33 +00:00
2013-11-25 18:40:52 +00:00
var parent = jqLite ( '<div><span></span></div>' ) ;
$rootElement . append ( parent ) ;
body . append ( $rootElement ) ;
var element = jqLite ( parent . find ( 'span' ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var signature = '' ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( element , 'klassy' , function ( ) {
signature += 'X' ;
} ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$timeout . flush ( 500 ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . hasClass ( 'klassy' ) ) . toBe ( true ) ;
2013-08-21 19:03:41 +00:00
2013-11-25 18:40:52 +00:00
$animate . removeClass ( element , 'klassy' , function ( ) {
signature += 'Y' ;
} ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$timeout . flush ( 3000 ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . hasClass ( 'klassy' ) ) . toBe ( false ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( signature ) . toBe ( 'XY' ) ;
} ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should properly execute CSS animations/transitions and use callbacks when using addClass / removeClass" ,
inject ( function ( $animate , $rootScope , $sniffer , $rootElement , $timeout ) {
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.klass-add' , '-webkit-transition:11s linear all;' +
'transition:11s linear all;' ) ;
ss . addRule ( '.klass-remove' , '-webkit-transition:11s linear all;' +
'transition:11s linear all;' ) ;
2013-08-28 23:18:33 +00:00
2013-11-25 18:40:52 +00:00
var parent = jqLite ( '<div><span></span></div>' ) ;
$rootElement . append ( parent ) ;
body . append ( $rootElement ) ;
var element = jqLite ( parent . find ( 'span' ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var signature = '' ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( element , 'klass' , function ( ) {
signature += 'd' ;
} ) ;
2013-08-25 21:44:05 +00:00
2013-11-25 18:40:52 +00:00
if ( $sniffer . transitions ) {
$timeout . flush ( ) ;
expect ( element . hasClass ( 'klass-add' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'klass-add-active' ) ) . toBe ( true ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : Date . now ( ) + 11000 , elapsedTime : 11 } ) ;
expect ( element . hasClass ( 'klass-add' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'klass-add-active' ) ) . toBe ( false ) ;
}
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$timeout . flush ( ) ;
expect ( element . hasClass ( 'klass' ) ) . toBe ( true ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$animate . removeClass ( element , 'klass' , function ( ) {
signature += 'b' ;
} ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
if ( $sniffer . transitions ) {
$timeout . flush ( ) ;
expect ( element . hasClass ( 'klass-remove' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'klass-remove-active' ) ) . toBe ( true ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : Date . now ( ) + 11000 , elapsedTime : 11 } ) ;
expect ( element . hasClass ( 'klass-remove' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'klass-remove-active' ) ) . toBe ( false ) ;
}
2013-08-21 19:03:41 +00:00
2013-11-25 18:40:52 +00:00
$timeout . flush ( ) ;
expect ( element . hasClass ( 'klass' ) ) . toBe ( false ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( signature ) . toBe ( 'db' ) ;
} ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should allow for multiple css classes to be animated plus a callback when added" ,
inject ( function ( $animate , $rootScope , $sniffer , $rootElement , $timeout ) {
2013-07-22 19:37:45 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.one-add' , '-webkit-transition:7s linear all;' +
'transition:7s linear all;' ) ;
ss . addRule ( '.two-add' , '-webkit-transition:7s linear all;' +
'transition:7s linear all;' ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var parent = jqLite ( '<div><span></span></div>' ) ;
$rootElement . append ( parent ) ;
body . append ( $rootElement ) ;
var element = jqLite ( parent . find ( 'span' ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var flag = false ;
$animate . addClass ( element , 'one two' , function ( ) {
flag = true ;
} ) ;
2013-08-21 19:03:41 +00:00
2013-11-25 18:40:52 +00:00
if ( $sniffer . transitions ) {
$timeout . flush ( ) ;
expect ( element . hasClass ( 'one-add' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'two-add' ) ) . toBe ( true ) ;
2013-07-22 19:37:45 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . hasClass ( 'one-add-active' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'two-add-active' ) ) . toBe ( true ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : Date . now ( ) + 7000 , elapsedTime : 7 } ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . hasClass ( 'one-add' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'one-add-active' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'two-add' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'two-add-active' ) ) . toBe ( false ) ;
}
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
$timeout . flush ( ) ;
2013-09-26 18:29:18 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . hasClass ( 'one' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'two' ) ) . toBe ( true ) ;
2013-09-26 18:29:18 +00:00
2013-11-25 18:40:52 +00:00
expect ( flag ) . toBe ( true ) ;
} ) ) ;
2013-09-06 14:41:45 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should allow for multiple css classes to be animated plus a callback when removed" ,
inject ( function ( $animate , $rootScope , $sniffer , $rootElement , $timeout ) {
2013-09-26 18:29:18 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.one-remove' , '-webkit-transition:9s linear all;' +
'transition:9s linear all;' ) ;
ss . addRule ( '.two-remove' , '-webkit-transition:9s linear all;' +
'transition:9s linear all;' ) ;
2013-09-26 18:29:18 +00:00
2013-11-25 18:40:52 +00:00
var parent = jqLite ( '<div><span></span></div>' ) ;
$rootElement . append ( parent ) ;
body . append ( $rootElement ) ;
var element = jqLite ( parent . find ( 'span' ) ) ;
2013-09-26 18:29:18 +00:00
2013-11-25 18:40:52 +00:00
element . addClass ( 'one two' ) ;
expect ( element . hasClass ( 'one' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'two' ) ) . toBe ( true ) ;
2013-09-26 18:29:18 +00:00
2013-11-25 18:40:52 +00:00
var flag = false ;
$animate . removeClass ( element , 'one two' , function ( ) {
flag = true ;
} ) ;
2013-09-26 18:29:18 +00:00
2013-11-25 18:40:52 +00:00
if ( $sniffer . transitions ) {
$timeout . flush ( ) ;
expect ( element . hasClass ( 'one-remove' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'two-remove' ) ) . toBe ( true ) ;
2013-09-26 18:29:18 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . hasClass ( 'one-remove-active' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'two-remove-active' ) ) . toBe ( true ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : Date . now ( ) + 9000 , elapsedTime : 9 } ) ;
2013-09-26 18:29:18 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . hasClass ( 'one-remove' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'one-remove-active' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'two-remove' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'two-remove-active' ) ) . toBe ( false ) ;
}
2013-09-26 18:29:18 +00:00
2013-11-25 18:40:52 +00:00
$timeout . flush ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . hasClass ( 'one' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'two' ) ) . toBe ( false ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( flag ) . toBe ( true ) ;
} ) ) ;
} ) ;
} ) ;
2013-08-21 19:03:41 +00:00
2013-11-25 18:40:52 +00:00
var $rootElement , $document ;
beforeEach ( module ( function ( ) {
return function ( _$rootElement _ , _$document _ , $animate ) {
$rootElement = _$rootElement _ ;
$document = _$document _ ;
$animate . enabled ( true ) ;
}
} ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
function html ( element ) {
var body = jqLite ( $document [ 0 ] . body ) ;
$rootElement . append ( element ) ;
body . append ( $rootElement ) ;
return element ;
}
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should properly animate and parse CSS3 transitions" ,
inject ( function ( $compile , $rootScope , $animate , $sniffer , $timeout ) {
2013-08-21 19:03:41 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.ng-enter' , '-webkit-transition:1s linear all;' +
'transition:1s linear all;' ) ;
2013-08-21 19:03:41 +00:00
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
var element = html ( $compile ( '<div>...</div>' ) ( $rootScope ) ) ;
2013-08-21 19:03:41 +00:00
var child = $compile ( '<div>...</div>' ) ( $rootScope ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
$animate . enter ( child , element ) ;
2013-08-28 23:32:20 +00:00
$rootScope . $digest ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
if ( $sniffer . transitions ) {
2013-11-25 18:40:52 +00:00
$timeout . flush ( ) ;
expect ( child . hasClass ( 'ng-enter' ) ) . toBe ( true ) ;
expect ( child . hasClass ( 'ng-enter-active' ) ) . toBe ( true ) ;
2013-11-04 20:55:01 +00:00
browserTrigger ( child , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
}
2013-11-25 18:40:52 +00:00
expect ( child . hasClass ( 'ng-enter' ) ) . toBe ( false ) ;
expect ( child . hasClass ( 'ng-enter-active' ) ) . toBe ( false ) ;
} ) ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should properly animate and parse CSS3 animations" ,
inject ( function ( $compile , $rootScope , $animate , $sniffer , $timeout ) {
ss . addRule ( '.ng-enter' , '-webkit-animation: some_animation 4s linear 1s 2 alternate;' +
'animation: some_animation 4s linear 1s 2 alternate;' ) ;
2013-08-21 19:03:41 +00:00
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
var element = html ( $compile ( '<div>...</div>' ) ( $rootScope ) ) ;
2013-08-21 19:03:41 +00:00
var child = $compile ( '<div>...</div>' ) ( $rootScope ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
$animate . enter ( child , element ) ;
2013-08-28 23:32:20 +00:00
$rootScope . $digest ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
if ( $sniffer . transitions ) {
2013-10-07 18:35:24 +00:00
$timeout . flush ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
expect ( child . hasClass ( 'ng-enter' ) ) . toBe ( true ) ;
2013-08-28 23:18:33 +00:00
expect ( child . hasClass ( 'ng-enter-active' ) ) . toBe ( true ) ;
2013-11-25 18:40:52 +00:00
browserTrigger ( child , 'transitionend' , { timeStamp : Date . now ( ) + 9000 , elapsedTime : 9 } ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
}
2013-11-25 18:40:52 +00:00
expect ( child . hasClass ( 'ng-enter' ) ) . toBe ( false ) ;
expect ( child . hasClass ( 'ng-enter-active' ) ) . toBe ( false ) ;
} ) ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should not set the transition property flag if only CSS animations are used" ,
inject ( function ( $compile , $rootScope , $animate , $sniffer , $timeout ) {
if ( ! $sniffer . animations ) return ;
ss . addRule ( '.sleek-animation.ng-enter' , '-webkit-animation: my_animation 2s linear;' +
'animation: my_animation 2s linear' ) ;
ss . addRule ( '.trans.ng-enter' , '-webkit-transition:1s linear all;' +
'transition:1s linear all' ) ;
var propertyKey = ( $sniffer . vendorPrefix == 'Webkit' ? '-webkit-' : '' ) + 'transition-property' ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
var element = html ( $compile ( '<div>...</div>' ) ( $rootScope ) ) ;
var child = $compile ( '<div class="skeep-animation">...</div>' ) ( $rootScope ) ;
child . css ( propertyKey , 'background-color' ) ;
$animate . enter ( child , element ) ;
2013-08-28 23:32:20 +00:00
$rootScope . $digest ( ) ;
2013-10-07 18:35:24 +00:00
$timeout . flush ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
browserTrigger ( child , 'transitionend' , { timeStamp : Date . now ( ) + 2000 , elapsedTime : 2 } ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( child . css ( propertyKey ) ) . toBe ( 'background-color' ) ;
child . remove ( ) ;
2013-07-22 19:37:45 +00:00
2013-11-25 18:40:52 +00:00
child = $compile ( '<div class="sleek-animation">...</div>' ) ( $rootScope ) ;
child . attr ( 'class' , 'trans' ) ;
$animate . enter ( child , element ) ;
$rootScope . $digest ( ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-11-25 18:40:52 +00:00
expect ( child . css ( propertyKey ) ) . not . toBe ( 'background-color' ) ;
} ) ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should skip animations if the browser does not support CSS3 transitions and CSS3 animations" ,
inject ( function ( $compile , $rootScope , $animate , $sniffer ) {
$sniffer . animations = false ;
$sniffer . transitions = false ;
2013-11-02 18:14:13 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.ng-enter' , '-webkit-animation: some_animation 4s linear 1s 2 alternate;' +
'animation: some_animation 4s linear 1s 2 alternate;' ) ;
2013-11-02 18:14:13 +00:00
var element = html ( $compile ( '<div>...</div>' ) ( $rootScope ) ) ;
2013-11-25 18:40:52 +00:00
var child = $compile ( '<div>...</div>' ) ( $rootScope ) ;
2013-11-02 18:14:13 +00:00
2013-11-25 18:40:52 +00:00
expect ( child . hasClass ( 'ng-enter' ) ) . toBe ( false ) ;
2013-11-02 18:14:13 +00:00
$animate . enter ( child , element ) ;
$rootScope . $digest ( ) ;
2013-11-25 18:40:52 +00:00
expect ( child . hasClass ( 'ng-enter' ) ) . toBe ( false ) ;
} ) ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should run other defined animations inline with CSS3 animations" , function ( ) {
module ( function ( $animateProvider ) {
$animateProvider . register ( '.custom' , function ( $timeout ) {
return {
enter : function ( element , done ) {
element . addClass ( 'i-was-animated' ) ;
$timeout ( done , 10 , false ) ;
}
}
} ) ;
} )
inject ( function ( $compile , $rootScope , $animate , $sniffer , $timeout ) {
2013-11-02 18:14:13 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.ng-enter' , '-webkit-transition: 1s linear all;' +
'transition: 1s linear all;' ) ;
2013-11-02 18:14:13 +00:00
2013-11-25 18:40:52 +00:00
var element = html ( $compile ( '<div>...</div>' ) ( $rootScope ) ) ;
var child = $compile ( '<div>...</div>' ) ( $rootScope ) ;
2013-11-02 18:14:13 +00:00
2013-11-25 18:40:52 +00:00
expect ( child . hasClass ( 'i-was-animated' ) ) . toBe ( false ) ;
child . addClass ( 'custom' ) ;
$animate . enter ( child , element ) ;
$rootScope . $digest ( ) ;
$timeout . flush ( 10 ) ;
if ( $sniffer . transitions ) {
browserTrigger ( child , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
}
expect ( child . hasClass ( 'i-was-animated' ) ) . toBe ( true ) ;
} ) ;
2013-11-02 18:14:13 +00:00
} ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should properly cancel CSS transitions or animations if another animation is fired" , function ( ) {
module ( function ( $animateProvider ) {
$animateProvider . register ( '.usurper' , function ( $timeout ) {
return {
leave : function ( element , done ) {
element . addClass ( 'this-is-mine-now' ) ;
$timeout ( done , 55 , false ) ;
2013-10-28 16:43:41 +00:00
}
}
2013-11-25 18:40:52 +00:00
} ) ;
} ) ;
inject ( function ( $compile , $rootScope , $animate , $sniffer , $timeout ) {
ss . addRule ( '.ng-enter' , '-webkit-transition: 2s linear all;' +
'transition: 2s linear all;' ) ;
ss . addRule ( '.ng-leave' , '-webkit-transition: 2s linear all;' +
'transition: 2s linear all;' ) ;
var element = html ( $compile ( '<div>...</div>' ) ( $rootScope ) ) ;
var child = $compile ( '<div>...</div>' ) ( $rootScope ) ;
$animate . enter ( child , element ) ;
$rootScope . $digest ( ) ;
//this is added/removed right away otherwise
if ( $sniffer . transitions ) {
$timeout . flush ( ) ;
expect ( child . hasClass ( 'ng-enter' ) ) . toBe ( true ) ;
expect ( child . hasClass ( 'ng-enter-active' ) ) . toBe ( true ) ;
2013-10-28 16:43:41 +00:00
}
2013-11-25 18:40:52 +00:00
expect ( child . hasClass ( 'this-is-mine-now' ) ) . toBe ( false ) ;
child . addClass ( 'usurper' ) ;
$animate . leave ( child ) ;
$rootScope . $digest ( ) ;
$timeout . flush ( ) ;
expect ( child . hasClass ( 'ng-enter' ) ) . toBe ( false ) ;
expect ( child . hasClass ( 'ng-enter-active' ) ) . toBe ( false ) ;
expect ( child . hasClass ( 'usurper' ) ) . toBe ( true ) ;
expect ( child . hasClass ( 'this-is-mine-now' ) ) . toBe ( true ) ;
$timeout . flush ( 55 ) ;
2013-10-28 16:43:41 +00:00
} ) ;
} ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should not perform the active class animation if the animation has been cancelled before the reflow occurs" , function ( ) {
inject ( function ( $compile , $rootScope , $animate , $sniffer , $timeout ) {
if ( ! $sniffer . transitions ) return ;
ss . addRule ( '.animated.ng-enter' , '-webkit-transition: 2s linear all;' +
'transition: 2s linear all;' ) ;
2013-10-28 16:43:41 +00:00
2013-11-25 18:40:52 +00:00
var element = html ( $compile ( '<div>...</div>' ) ( $rootScope ) ) ;
var child = $compile ( '<div class="animated">...</div>' ) ( $rootScope ) ;
2013-10-28 16:43:41 +00:00
2013-11-25 18:40:52 +00:00
$animate . enter ( child , element ) ;
$rootScope . $digest ( ) ;
expect ( child . hasClass ( 'ng-enter' ) ) . toBe ( true ) ;
$animate . leave ( child ) ;
$rootScope . $digest ( ) ;
2013-10-28 16:43:41 +00:00
2013-11-25 18:40:52 +00:00
$timeout . flush ( ) ;
expect ( child . hasClass ( 'ng-enter-active' ) ) . toBe ( false ) ;
} ) ;
2013-10-28 16:43:41 +00:00
} ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
2013-12-19 16:56:26 +00:00
//
2013-11-25 18:40:52 +00:00
// it("should add and remove CSS classes and perform CSS animations during the process",
// inject(function($compile, $rootScope, $animate, $sniffer, $timeout) {
//
// ss.addRule('.on-add', '-webkit-transition: 10s linear all; ' +
// 'transition: 10s linear all;');
// ss.addRule('.on-remove', '-webkit-transition: 10s linear all; ' +
// 'transition: 10s linear all;');
//
// var element = html($compile('<div></div>')($rootScope));
//
// expect(element.hasClass('on')).toBe(false);
//
// $animate.addClass(element, 'on');
//
// if($sniffer.transitions) {
// expect(element.hasClass('on')).toBe(false);
// expect(element.hasClass('on-add')).toBe(true);
// $timeout.flush();
// }
//
// $timeout.flush();
//
// expect(element.hasClass('on')).toBe(true);
// expect(element.hasClass('on-add')).toBe(false);
// expect(element.hasClass('on-add-active')).toBe(false);
//
// $animate.removeClass(element, 'on');
// if($sniffer.transitions) {
// expect(element.hasClass('on')).toBe(true);
// expect(element.hasClass('on-remove')).toBe(true);
// $timeout.flush(10000);
// }
//
// $timeout.flush();
// expect(element.hasClass('on')).toBe(false);
// expect(element.hasClass('on-remove')).toBe(false);
// expect(element.hasClass('on-remove-active')).toBe(false);
// }));
//
2013-12-19 16:56:26 +00:00
//
2013-11-25 18:40:52 +00:00
// it("should show and hide elements with CSS & JS animations being performed in the process", function() {
// module(function($animateProvider) {
// $animateProvider.register('.displayer', function($timeout) {
// return {
// removeClass : function(element, className, done) {
// element.removeClass('hiding');
// element.addClass('showing');
// $timeout(done, 25, false);
// },
// addClass : function(element, className, done) {
// element.removeClass('showing');
// element.addClass('hiding');
// $timeout(done, 555, false);
// }
// }
// });
// })
// inject(function($compile, $rootScope, $animate, $sniffer, $timeout) {
//
// ss.addRule('.ng-hide-add', '-webkit-transition: 5s linear all;' +
// 'transition: 5s linear all;');
// ss.addRule('.ng-hide-remove', '-webkit-transition: 5s linear all;' +
// 'transition: 5s linear all;');
//
// var element = html($compile('<div></div>')($rootScope));
//
// element.addClass('displayer');
//
// expect(element).toBeShown();
// expect(element.hasClass('showing')).toBe(false);
// expect(element.hasClass('hiding')).toBe(false);
//
// $animate.addClass(element, 'ng-hide');
//
// if($sniffer.transitions) {
// expect(element).toBeShown(); //still showing
// $timeout.flush();
// expect(element).toBeShown();
// $timeout.flush(5555);
// }
// $timeout.flush();
// expect(element).toBeHidden();
//
// expect(element.hasClass('showing')).toBe(false);
// expect(element.hasClass('hiding')).toBe(true);
// $animate.removeClass(element, 'ng-hide');
//
// if($sniffer.transitions) {
// expect(element).toBeHidden();
// $timeout.flush();
// expect(element).toBeHidden();
// $timeout.flush(5580);
// }
// $timeout.flush();
// expect(element).toBeShown();
//
// expect(element.hasClass('showing')).toBe(true);
// expect(element.hasClass('hiding')).toBe(false);
// });
// });
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should remove all the previous classes when the next animation is applied before a reflow" , function ( ) {
var fn , interceptedClass ;
module ( function ( $animateProvider ) {
$animateProvider . register ( '.three' , function ( ) {
return {
move : function ( element , done ) {
fn = function ( ) {
done ( ) ;
}
return function ( ) {
interceptedClass = element . attr ( 'class' ) ;
}
}
2013-08-06 18:15:01 +00:00
}
2013-11-25 18:40:52 +00:00
} ) ;
2013-08-06 18:15:01 +00:00
} ) ;
2013-11-25 18:40:52 +00:00
inject ( function ( $compile , $rootScope , $animate , $timeout ) {
var parent = html ( $compile ( '<div class="parent"></div>' ) ( $rootScope ) ) ;
var one = $compile ( '<div class="one"></div>' ) ( $rootScope ) ;
var two = $compile ( '<div class="two"></div>' ) ( $rootScope ) ;
var three = $compile ( '<div class="three klass"></div>' ) ( $rootScope ) ;
2013-08-06 18:15:01 +00:00
2013-11-25 18:40:52 +00:00
parent . append ( one ) ;
parent . append ( two ) ;
parent . append ( three ) ;
$animate . move ( three , null , two ) ;
$rootScope . $digest ( ) ;
2013-08-06 18:15:01 +00:00
2013-11-25 18:40:52 +00:00
$animate . move ( three , null , one ) ;
$rootScope . $digest ( ) ;
2013-08-06 18:15:01 +00:00
2013-11-25 18:40:52 +00:00
//this means that the former animation was cleaned up before the new one starts
expect ( interceptedClass . indexOf ( 'ng-animate' ) >= 0 ) . toBe ( false ) ;
} ) ;
2013-08-06 18:15:01 +00:00
} ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should provide the correct CSS class to the addClass and removeClass callbacks within a JS animation" , function ( ) {
module ( function ( $animateProvider ) {
$animateProvider . register ( '.classify' , function ( ) {
return {
removeClass : function ( element , className , done ) {
element . data ( 'classify' , 'remove-' + className ) ;
done ( ) ;
} ,
addClass : function ( element , className , done ) {
element . data ( 'classify' , 'add-' + className ) ;
done ( ) ;
}
}
} ) ;
} )
inject ( function ( $compile , $rootScope , $animate ) {
var element = html ( $compile ( '<div class="classify"></div>' ) ( $rootScope ) ) ;
2013-08-22 13:30:11 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( element , 'super' ) ;
expect ( element . data ( 'classify' ) ) . toBe ( 'add-super' ) ;
2013-08-22 13:30:11 +00:00
2013-11-25 18:40:52 +00:00
$animate . removeClass ( element , 'super' ) ;
expect ( element . data ( 'classify' ) ) . toBe ( 'remove-super' ) ;
2013-08-22 13:30:11 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( element , 'superguy' ) ;
expect ( element . data ( 'classify' ) ) . toBe ( 'add-superguy' ) ;
} ) ;
} ) ;
2013-08-22 13:30:11 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should not skip ngAnimate animations when any pre-existing CSS transitions are present on the element" , function ( ) {
inject ( function ( $compile , $rootScope , $animate , $timeout , $sniffer ) {
if ( ! $sniffer . transitions ) return ;
2013-08-22 13:30:11 +00:00
2013-11-25 18:40:52 +00:00
var element = html ( $compile ( '<div class="animated parent"></div>' ) ( $rootScope ) ) ;
var child = html ( $compile ( '<div class="animated child"></div>' ) ( $rootScope ) ) ;
2013-08-22 13:30:11 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.animated' , '-webkit-transition:1s linear all;' +
'transition:1s linear all;' ) ;
ss . addRule ( '.super-add' , '-webkit-transition:2s linear all;' +
'transition:2s linear all;' ) ;
$rootElement . append ( element ) ;
jqLite ( document . body ) . append ( $rootElement ) ;
$animate . addClass ( element , 'super' ) ;
var empty = true ;
try {
$timeout . flush ( ) ;
empty = false ;
}
catch ( e ) { }
expect ( empty ) . toBe ( false ) ;
} ) ;
2013-08-22 13:30:11 +00:00
} ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should wait until both the duration and delay are complete to close off the animation" ,
inject ( function ( $compile , $rootScope , $animate , $timeout , $sniffer ) {
2013-09-25 04:20:25 +00:00
2013-11-25 18:40:52 +00:00
if ( ! $sniffer . transitions ) return ;
2013-09-25 04:20:25 +00:00
2013-11-25 18:40:52 +00:00
var element = html ( $compile ( '<div class="animated parent"></div>' ) ( $rootScope ) ) ;
var child = html ( $compile ( '<div class="animated child"></div>' ) ( $rootScope ) ) ;
2013-09-25 04:20:25 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.animated.ng-enter' , '-webkit-transition: width 1s, background 1s 1s;' +
'transition: width 1s, background 1s 1s;' ) ;
2013-09-25 04:20:25 +00:00
2013-11-25 18:40:52 +00:00
$rootElement . append ( element ) ;
jqLite ( document . body ) . append ( $rootElement ) ;
2013-09-25 04:20:25 +00:00
2013-11-25 18:40:52 +00:00
$animate . enter ( child , element ) ;
$rootScope . $digest ( ) ;
$timeout . flush ( ) ;
2013-09-25 04:20:25 +00:00
2013-11-25 18:40:52 +00:00
expect ( child . hasClass ( 'ng-enter' ) ) . toBe ( true ) ;
expect ( child . hasClass ( 'ng-enter-active' ) ) . toBe ( true ) ;
2013-09-25 04:20:25 +00:00
2013-11-25 18:40:52 +00:00
browserTrigger ( child , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 0 } ) ;
2013-09-25 04:20:25 +00:00
2013-11-25 18:40:52 +00:00
expect ( child . hasClass ( 'ng-enter' ) ) . toBe ( true ) ;
expect ( child . hasClass ( 'ng-enter-active' ) ) . toBe ( true ) ;
2013-09-25 04:20:25 +00:00
2013-11-25 18:40:52 +00:00
browserTrigger ( child , 'transitionend' , { timeStamp : Date . now ( ) + 2000 , elapsedTime : 2 } ) ;
2013-09-25 04:20:25 +00:00
2013-11-25 18:40:52 +00:00
expect ( child . hasClass ( 'ng-enter' ) ) . toBe ( false ) ;
expect ( child . hasClass ( 'ng-enter-active' ) ) . toBe ( false ) ;
2013-09-25 04:20:25 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . contents ( ) . length ) . toBe ( 1 ) ;
} ) ) ;
2013-09-25 04:20:25 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should cancel all child animations when a leave or move animation is triggered on a parent element" , function ( ) {
2013-10-10 13:16:19 +00:00
2013-11-25 18:40:52 +00:00
var step , animationState ;
module ( function ( $animateProvider ) {
$animateProvider . register ( '.animan' , function ( $timeout ) {
return {
enter : function ( element , done ) {
animationState = 'enter' ;
step = done ;
return function ( cancelled ) {
animationState = cancelled ? 'enter-cancel' : animationState ;
}
} ,
addClass : function ( element , className , done ) {
animationState = 'addClass' ;
step = done ;
return function ( cancelled ) {
animationState = cancelled ? 'addClass-cancel' : animationState ;
}
2013-10-10 13:16:19 +00:00
}
2013-11-25 18:40:52 +00:00
} ;
} ) ;
2013-10-10 13:16:19 +00:00
} ) ;
2013-11-25 18:40:52 +00:00
inject ( function ( $animate , $compile , $rootScope , $timeout , $sniffer ) {
var element = html ( $compile ( '<div class="parent"></div>' ) ( $rootScope ) ) ;
var container = html ( $compile ( '<div class="container"></div>' ) ( $rootScope ) ) ;
var child = html ( $compile ( '<div class="animan child"></div>' ) ( $rootScope ) ) ;
2013-10-10 13:16:19 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.animan.ng-enter, .animan.something-add' , '-webkit-transition: width 1s, background 1s 1s;' +
'transition: width 1s, background 1s 1s;' ) ;
2013-10-10 13:16:19 +00:00
2013-11-25 18:40:52 +00:00
$rootElement . append ( element ) ;
jqLite ( document . body ) . append ( $rootElement ) ;
2013-10-10 13:16:19 +00:00
2013-11-25 18:40:52 +00:00
$animate . enter ( child , element ) ;
$rootScope . $digest ( ) ;
expect ( animationState ) . toBe ( 'enter' ) ;
if ( $sniffer . transitions ) {
expect ( child . hasClass ( 'ng-enter' ) ) . toBe ( true ) ;
$timeout . flush ( ) ;
expect ( child . hasClass ( 'ng-enter-active' ) ) . toBe ( true ) ;
}
2013-10-10 13:16:19 +00:00
2013-11-25 18:40:52 +00:00
$animate . move ( element , container ) ;
if ( $sniffer . transitions ) {
expect ( child . hasClass ( 'ng-enter' ) ) . toBe ( false ) ;
expect ( child . hasClass ( 'ng-enter-active' ) ) . toBe ( false ) ;
}
2013-11-04 21:23:56 +00:00
2013-11-25 18:40:52 +00:00
expect ( animationState ) . toBe ( 'enter-cancel' ) ;
2013-10-10 13:16:19 +00:00
2013-11-25 18:40:52 +00:00
$rootScope . $digest ( ) ;
2013-11-04 21:23:56 +00:00
$timeout . flush ( ) ;
2013-10-10 13:16:19 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( child , 'something' ) ;
if ( $sniffer . transitions ) {
$timeout . flush ( ) ;
}
expect ( animationState ) . toBe ( 'addClass' ) ;
if ( $sniffer . transitions ) {
expect ( child . hasClass ( 'something-add' ) ) . toBe ( true ) ;
expect ( child . hasClass ( 'something-add-active' ) ) . toBe ( true ) ;
}
$animate . leave ( container ) ;
expect ( animationState ) . toBe ( 'addClass-cancel' ) ;
if ( $sniffer . transitions ) {
expect ( child . hasClass ( 'something-add' ) ) . toBe ( false ) ;
expect ( child . hasClass ( 'something-add-active' ) ) . toBe ( false ) ;
}
} ) ;
2013-10-10 13:16:19 +00:00
} ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should wait until a queue of animations are complete before performing a reflow" ,
inject ( function ( $rootScope , $compile , $timeout , $sniffer ) {
2013-10-07 18:35:24 +00:00
2013-11-25 18:40:52 +00:00
if ( ! $sniffer . transitions ) return ;
2013-10-07 18:35:24 +00:00
2013-11-25 18:40:52 +00:00
$rootScope . items = [ 1 , 2 , 3 , 4 , 5 ] ;
var element = html ( $compile ( '<div><div class="animated" ng-repeat="item in items"></div></div>' ) ( $rootScope ) ) ;
2013-10-07 18:35:24 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.animated.ng-enter' , '-webkit-transition: width 1s, background 1s 1s;' +
'transition: width 1s, background 1s 1s;' ) ;
2013-10-07 18:35:24 +00:00
2013-11-25 18:40:52 +00:00
$rootScope . $digest ( ) ;
expect ( element [ 0 ] . querySelectorAll ( '.ng-enter-active' ) . length ) . toBe ( 0 ) ;
$timeout . flush ( ) ;
expect ( element [ 0 ] . querySelectorAll ( '.ng-enter-active' ) . length ) . toBe ( 5 ) ;
2013-10-07 18:35:24 +00:00
2013-11-25 18:40:52 +00:00
forEach ( element . children ( ) , function ( kid ) {
browserTrigger ( kid , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
} ) ;
2013-10-07 18:35:24 +00:00
2013-11-25 18:40:52 +00:00
expect ( element [ 0 ] . querySelectorAll ( '.ng-enter-active' ) . length ) . toBe ( 0 ) ;
} ) ) ;
2013-10-07 18:35:24 +00:00
2013-10-09 03:40:46 +00:00
2013-11-25 18:40:52 +00:00
it ( "should work to disable all child animations for an element" , function ( ) {
var childAnimated = false ,
containerAnimated = false ;
module ( function ( $animateProvider ) {
$animateProvider . register ( '.child' , function ( ) {
return {
addClass : function ( element , className , done ) {
childAnimated = true ;
done ( ) ;
}
2013-10-09 03:40:46 +00:00
}
2013-11-25 18:40:52 +00:00
} ) ;
$animateProvider . register ( '.container' , function ( ) {
return {
leave : function ( element , done ) {
containerAnimated = true ;
done ( ) ;
}
2013-10-09 03:40:46 +00:00
}
2013-11-25 18:40:52 +00:00
} ) ;
2013-10-09 03:40:46 +00:00
} ) ;
2013-11-25 18:40:52 +00:00
inject ( function ( $compile , $rootScope , $animate , $timeout , $rootElement ) {
$animate . enabled ( true ) ;
2013-10-09 03:40:46 +00:00
2013-11-25 18:40:52 +00:00
var element = $compile ( '<div class="container"></div>' ) ( $rootScope ) ;
jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
$rootElement . append ( element ) ;
2013-10-09 03:40:46 +00:00
2013-11-25 18:40:52 +00:00
var child = $compile ( '<div class="child"></div>' ) ( $rootScope ) ;
element . append ( child ) ;
2013-10-09 03:40:46 +00:00
2013-11-25 18:40:52 +00:00
$animate . enabled ( true , element ) ;
2013-10-09 03:40:46 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( child , 'awesome' ) ;
expect ( childAnimated ) . toBe ( true ) ;
2013-10-09 03:40:46 +00:00
2013-11-25 18:40:52 +00:00
childAnimated = false ;
$animate . enabled ( false , element ) ;
2013-10-09 03:40:46 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( child , 'super' ) ;
expect ( childAnimated ) . toBe ( false ) ;
2013-10-09 03:40:46 +00:00
2013-11-25 18:40:52 +00:00
$animate . leave ( element ) ;
$rootScope . $digest ( ) ;
expect ( containerAnimated ) . toBe ( true ) ;
} ) ;
2013-10-09 03:40:46 +00:00
} ) ;
2013-11-25 18:40:52 +00:00
it ( "should disable all child animations on structural animations until the first reflow has passed" , function ( ) {
var intercepted ;
module ( function ( $animateProvider ) {
$animateProvider . register ( '.animated' , function ( ) {
return {
enter : ani ( 'enter' ) ,
leave : ani ( 'leave' ) ,
move : ani ( 'move' ) ,
addClass : ani ( 'addClass' ) ,
removeClass : ani ( 'removeClass' )
} ;
function ani ( type ) {
return function ( element , className , done ) {
intercepted = type ;
( done || className ) ( ) ;
}
2013-10-09 03:40:46 +00:00
}
2013-11-25 18:40:52 +00:00
} ) ;
2013-10-09 03:40:46 +00:00
} ) ;
2013-11-25 18:40:52 +00:00
inject ( function ( $animate , $rootScope , $sniffer , $timeout , $compile , _$rootElement _ ) {
$rootElement = _$rootElement _ ;
2013-10-09 03:40:46 +00:00
2013-11-25 18:40:52 +00:00
$animate . enabled ( true ) ;
$rootScope . $digest ( ) ;
2013-10-09 03:40:46 +00:00
2013-11-25 18:40:52 +00:00
var element = $compile ( '<div class="element animated">...</div>' ) ( $rootScope ) ;
var child1 = $compile ( '<div class="child1 animated">...</div>' ) ( $rootScope ) ;
var child2 = $compile ( '<div class="child2 animated">...</div>' ) ( $rootScope ) ;
var container = $compile ( '<div class="container">...</div>' ) ( $rootScope ) ;
2013-10-09 03:40:46 +00:00
2013-11-25 18:40:52 +00:00
jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
$rootElement . append ( container ) ;
element . append ( child1 ) ;
element . append ( child2 ) ;
2013-10-09 03:40:46 +00:00
2013-11-25 18:40:52 +00:00
$animate . move ( element , null , container ) ;
$rootScope . $digest ( ) ;
2013-10-09 03:40:46 +00:00
2013-11-25 18:40:52 +00:00
expect ( intercepted ) . toBe ( 'move' ) ;
2013-10-09 03:40:46 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( child1 , 'test' ) ;
expect ( child1 . hasClass ( 'test' ) ) . toBe ( true ) ;
2013-10-09 03:40:46 +00:00
2013-11-25 18:40:52 +00:00
expect ( intercepted ) . toBe ( 'move' ) ;
$animate . leave ( child1 ) ;
$rootScope . $digest ( ) ;
2013-10-09 03:40:46 +00:00
2013-11-25 18:40:52 +00:00
expect ( intercepted ) . toBe ( 'move' ) ;
2013-10-09 03:40:46 +00:00
2013-11-25 18:40:52 +00:00
//reflow has passed
$timeout . flush ( ) ;
2013-10-09 03:40:46 +00:00
2013-11-25 18:40:52 +00:00
$animate . leave ( child2 ) ;
$rootScope . $digest ( ) ;
expect ( intercepted ) . toBe ( 'leave' ) ;
} ) ;
2013-10-09 03:40:46 +00:00
} ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should not disable any child animations when any parent class-based animations are run" , function ( ) {
var intercepted ;
module ( function ( $animateProvider ) {
$animateProvider . register ( '.animated' , function ( ) {
return {
enter : function ( element , done ) {
intercepted = true ;
done ( ) ;
}
2013-10-09 03:40:46 +00:00
}
2013-11-25 18:40:52 +00:00
} ) ;
2013-10-09 03:40:46 +00:00
} ) ;
2013-11-25 18:40:52 +00:00
inject ( function ( $animate , $rootScope , $sniffer , $timeout , $compile , $document , $rootElement ) {
$animate . enabled ( true ) ;
2013-10-09 03:40:46 +00:00
2013-11-25 18:40:52 +00:00
var element = $compile ( '<div ng-class="{klass:bool}"> <div ng-if="bool" class="animated">value</div></div>' ) ( $rootScope ) ;
$rootElement . append ( element ) ;
jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
2013-10-09 03:40:46 +00:00
2013-11-25 18:40:52 +00:00
$rootScope . bool = true ;
$rootScope . $digest ( ) ;
expect ( intercepted ) . toBe ( true ) ;
} ) ;
2013-10-09 03:40:46 +00:00
} ) ;
2013-10-09 05:12:03 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should cache the response from getComputedStyle if each successive element has the same className value and parent until the first reflow hits" , function ( ) {
var count = 0 ;
module ( function ( $provide ) {
$provide . value ( '$window' , {
document : jqLite ( window . document ) ,
getComputedStyle : function ( element ) {
count ++ ;
return window . getComputedStyle ( element ) ;
}
} ) ;
2013-10-09 05:12:03 +00:00
} ) ;
2013-11-25 18:40:52 +00:00
inject ( function ( $animate , $rootScope , $compile , $rootElement , $timeout , $document , $sniffer ) {
if ( ! $sniffer . transitions ) return ;
2013-10-09 05:12:03 +00:00
2013-11-25 18:40:52 +00:00
$animate . enabled ( true ) ;
2013-10-09 05:12:03 +00:00
2013-11-25 18:40:52 +00:00
var element = $compile ( '<div></div>' ) ( $rootScope ) ;
$rootElement . append ( element ) ;
jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
2013-10-09 05:12:03 +00:00
2013-11-25 18:40:52 +00:00
for ( var i = 0 ; i < 20 ; i ++ ) {
var kid = $compile ( '<div class="kid"></div>' ) ( $rootScope ) ;
$animate . enter ( kid , element ) ;
}
$rootScope . $digest ( ) ;
$timeout . flush ( ) ;
2013-10-09 05:12:03 +00:00
2013-11-25 18:40:52 +00:00
//called three times since the classname is the same
expect ( count ) . toBe ( 2 ) ;
2013-10-09 05:12:03 +00:00
2013-11-25 18:40:52 +00:00
dealoc ( element ) ;
count = 0 ;
2013-10-09 05:12:03 +00:00
2013-11-25 18:40:52 +00:00
for ( var i = 0 ; i < 20 ; i ++ ) {
var kid = $compile ( '<div class="kid c-' + i + '"></div>' ) ( $rootScope ) ;
$animate . enter ( kid , element ) ;
}
2013-10-09 05:12:03 +00:00
2013-11-25 18:40:52 +00:00
$rootScope . $digest ( ) ;
$timeout . flush ( ) ;
2013-10-09 05:12:03 +00:00
2013-11-25 18:40:52 +00:00
expect ( count ) . toBe ( 20 ) ;
} ) ;
2013-10-09 05:12:03 +00:00
} ) ;
2013-10-18 02:37:17 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should cancel an ongoing class-based animation only if the new class contains transition/animation CSS code" ,
inject ( function ( $compile , $rootScope , $animate , $sniffer , $timeout ) {
2013-10-18 02:37:17 +00:00
2013-11-25 18:40:52 +00:00
if ( ! $sniffer . transitions ) return ;
2013-10-18 02:37:17 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.green-add' , '-webkit-transition:1s linear all;' +
'transition:1s linear all;' ) ;
2013-10-18 02:37:17 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.blue-add' , 'background:blue;' ) ;
2013-10-18 02:37:17 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.red-add' , '-webkit-transition:1s linear all;' +
'transition:1s linear all;' ) ;
2013-10-18 02:37:17 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.yellow-add' , '-webkit-animation: some_animation 4s linear 1s 2 alternate;' +
'animation: some_animation 4s linear 1s 2 alternate;' ) ;
2013-10-18 02:37:17 +00:00
2013-11-25 18:40:52 +00:00
var element = $compile ( '<div></div>' ) ( $rootScope ) ;
$rootElement . append ( element ) ;
jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
2013-10-18 02:37:17 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( element , 'green' ) ;
expect ( element . hasClass ( 'green-add' ) ) . toBe ( true ) ;
$animate . addClass ( element , 'blue' ) ;
expect ( element . hasClass ( 'blue' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'green-add' ) ) . toBe ( true ) ; //not cancelled
2013-10-18 02:37:17 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( element , 'red' ) ;
expect ( element . hasClass ( 'green-add' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'red-add' ) ) . toBe ( true ) ;
2013-10-22 05:53:40 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( element , 'yellow' ) ;
expect ( element . hasClass ( 'red-add' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'yellow-add' ) ) . toBe ( true ) ;
} ) ) ;
2013-11-16 05:43:08 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( "should cancel and perform the dom operation only after the reflow has run" ,
inject ( function ( $compile , $rootScope , $animate , $sniffer , $timeout ) {
2013-11-16 05:43:08 +00:00
2013-11-25 18:40:52 +00:00
if ( ! $sniffer . transitions ) return ;
2013-11-16 05:43:08 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.green-add' , '-webkit-transition:1s linear all;' +
'transition:1s linear all;' ) ;
2013-11-16 05:43:08 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.red-add' , '-webkit-transition:1s linear all;' +
'transition:1s linear all;' ) ;
2013-11-16 05:43:08 +00:00
2013-11-25 18:40:52 +00:00
var element = $compile ( '<div></div>' ) ( $rootScope ) ;
$rootElement . append ( element ) ;
jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
2013-11-16 05:43:08 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( element , 'green' ) ;
expect ( element . hasClass ( 'green-add' ) ) . toBe ( true ) ;
2013-11-16 05:43:08 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( element , 'red' ) ;
expect ( element . hasClass ( 'red-add' ) ) . toBe ( true ) ;
2013-11-16 05:43:08 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . hasClass ( 'green' ) ) . toBe ( false ) ;
expect ( element . hasClass ( 'red' ) ) . toBe ( false ) ;
2013-11-16 05:43:08 +00:00
2013-11-25 18:40:52 +00:00
$timeout . flush ( ) ;
2013-11-16 05:43:08 +00:00
2013-11-25 18:40:52 +00:00
expect ( element . hasClass ( 'green' ) ) . toBe ( true ) ;
expect ( element . hasClass ( 'red' ) ) . toBe ( true ) ;
} ) ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( 'should enable and disable animations properly on the root element' , function ( ) {
var count = 0 ;
module ( function ( $animateProvider ) {
$animateProvider . register ( '.animated' , function ( ) {
return {
addClass : function ( element , className , done ) {
count ++ ;
done ( ) ;
}
2013-10-22 05:53:40 +00:00
}
2013-11-25 18:40:52 +00:00
} ) ;
2013-10-22 05:53:40 +00:00
} ) ;
2013-11-25 18:40:52 +00:00
inject ( function ( $compile , $rootScope , $animate , $sniffer , $rootElement , $timeout ) {
2013-10-22 05:53:40 +00:00
2013-11-25 18:40:52 +00:00
$rootElement . addClass ( 'animated' ) ;
$animate . addClass ( $rootElement , 'green' ) ;
expect ( count ) . toBe ( 1 ) ;
2013-10-22 05:53:40 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( $rootElement , 'red' ) ;
expect ( count ) . toBe ( 2 ) ;
} ) ;
2013-10-22 05:53:40 +00:00
} ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( 'should perform pre and post animations' , function ( ) {
var steps = [ ] ;
module ( function ( $animateProvider ) {
$animateProvider . register ( '.class-animate' , function ( ) {
return {
beforeAddClass : function ( element , className , done ) {
steps . push ( 'before' ) ;
done ( ) ;
} ,
addClass : function ( element , className , done ) {
steps . push ( 'after' ) ;
done ( ) ;
}
} ;
} ) ;
2013-11-04 21:23:56 +00:00
} ) ;
2013-11-25 18:40:52 +00:00
inject ( function ( $animate , $rootScope , $compile , $rootElement , $timeout ) {
$animate . enabled ( true ) ;
2013-11-04 21:23:56 +00:00
2013-11-25 18:40:52 +00:00
var element = $compile ( '<div class="class-animate"></div>' ) ( $rootScope ) ;
$rootElement . append ( element ) ;
2013-11-04 21:23:56 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( element , 'red' ) ;
2013-11-04 21:23:56 +00:00
2013-11-25 18:40:52 +00:00
expect ( steps ) . toEqual ( [ 'before' , 'after' ] ) ;
} ) ;
2013-11-04 21:23:56 +00:00
} ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( 'should treat the leave event always as a before event and discard the beforeLeave function' , function ( ) {
var parentID , steps = [ ] ;
module ( function ( $animateProvider ) {
$animateProvider . register ( '.animate' , function ( ) {
return {
beforeLeave : function ( element , done ) {
steps . push ( 'before' ) ;
done ( ) ;
} ,
leave : function ( element , done ) {
parentID = element . parent ( ) . attr ( 'id' ) ;
steps . push ( 'after' ) ;
done ( ) ;
}
} ;
} ) ;
2013-11-04 21:23:56 +00:00
} ) ;
2013-11-25 18:40:52 +00:00
inject ( function ( $animate , $rootScope , $compile , $rootElement ) {
$animate . enabled ( true ) ;
2013-11-04 21:23:56 +00:00
2013-11-25 18:40:52 +00:00
var element = $compile ( '<div id="parentGuy"></div>' ) ( $rootScope ) ;
var child = $compile ( '<div class="animate"></div>' ) ( $rootScope ) ;
$rootElement . append ( element ) ;
element . append ( child ) ;
2013-11-04 21:23:56 +00:00
2013-11-25 18:40:52 +00:00
$animate . leave ( child ) ;
$rootScope . $digest ( ) ;
2013-11-04 21:23:56 +00:00
2013-11-25 18:40:52 +00:00
expect ( steps ) . toEqual ( [ 'after' ] ) ;
expect ( parentID ) . toEqual ( 'parentGuy' ) ;
} ) ;
2013-11-04 21:23:56 +00:00
} ) ;
2013-11-14 20:36:07 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( 'should only perform the DOM operation once' ,
inject ( function ( $sniffer , $compile , $rootScope , $rootElement , $animate , $timeout ) {
2013-11-14 20:36:07 +00:00
2013-11-25 18:40:52 +00:00
if ( ! $sniffer . transitions ) return ;
2013-11-14 20:36:07 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.base-class' , '-webkit-transition:1s linear all;' +
'transition:1s linear all;' ) ;
2013-11-14 20:36:07 +00:00
2013-11-25 18:40:52 +00:00
$animate . enabled ( true ) ;
2013-11-14 20:36:07 +00:00
2013-11-25 18:40:52 +00:00
var element = $compile ( '<div class="base-class one two"></div>' ) ( $rootScope ) ;
$rootElement . append ( element ) ;
jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
2013-11-14 20:36:07 +00:00
2013-11-25 18:40:52 +00:00
$animate . removeClass ( element , 'base-class one two' ) ;
2013-11-14 20:36:07 +00:00
2013-11-25 18:40:52 +00:00
//still true since we're before the reflow
expect ( element . hasClass ( 'base-class' ) ) . toBe ( true ) ;
2013-11-14 20:36:07 +00:00
2013-11-25 18:40:52 +00:00
//this will cancel the remove animation
$animate . addClass ( element , 'base-class one two' ) ;
2013-11-14 20:36:07 +00:00
2013-11-25 18:40:52 +00:00
//the cancellation was a success and the class was added right away
//since there was no successive animation for the after animation
expect ( element . hasClass ( 'base-class' ) ) . toBe ( true ) ;
2013-11-14 20:36:07 +00:00
2013-11-25 18:40:52 +00:00
//the reflow...
$timeout . flush ( ) ;
2013-11-14 20:36:07 +00:00
2013-11-25 18:40:52 +00:00
//the reflow DOM operation was commenced but it ran before so it
//shouldn't run agaun
expect ( element . hasClass ( 'base-class' ) ) . toBe ( true ) ;
} ) ) ;
2013-11-18 21:20:22 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( 'should block and unblock transitions before the dom operation occurs' ,
inject ( function ( $rootScope , $compile , $rootElement , $document , $animate , $sniffer , $timeout ) {
2013-11-18 21:20:22 +00:00
2013-11-25 18:40:52 +00:00
if ( ! $sniffer . transitions ) return ;
2013-11-18 21:20:22 +00:00
2013-11-25 18:40:52 +00:00
$animate . enabled ( true ) ;
2013-11-18 21:20:22 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.cross-animation' , '-webkit-transition:1s linear all;' +
'transition:1s linear all;' ) ;
2013-11-18 21:20:22 +00:00
2013-11-25 18:40:52 +00:00
var capturedProperty = 'none' ;
2013-11-18 21:20:22 +00:00
2013-11-25 18:40:52 +00:00
var element = $compile ( '<div class="cross-animation"></div>' ) ( $rootScope ) ;
$rootElement . append ( element ) ;
jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
2013-11-18 21:20:22 +00:00
2013-11-25 18:40:52 +00:00
var node = element [ 0 ] ;
node . _setAttribute = node . setAttribute ;
node . setAttribute = function ( prop , val ) {
if ( prop == 'class' && val . indexOf ( 'trigger-class' ) >= 0 ) {
var propertyKey = ( $sniffer . vendorPrefix == 'Webkit' ? '-webkit-' : '' ) + 'transition-property' ;
capturedProperty = element . css ( propertyKey ) ;
}
node . _setAttribute ( prop , val ) ;
} ;
2013-11-18 21:20:22 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( element , 'trigger-class' ) ;
2013-11-18 21:20:22 +00:00
2013-11-25 18:40:52 +00:00
$timeout . flush ( ) ;
2013-11-18 21:20:22 +00:00
2013-11-25 18:40:52 +00:00
expect ( capturedProperty ) . not . toBe ( 'none' ) ;
} ) ) ;
2013-11-19 05:21:48 +00:00
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( 'should block and unblock keyframe animations around the reflow operation' ,
inject ( function ( $rootScope , $compile , $rootElement , $document , $animate , $sniffer , $timeout ) {
2013-11-19 05:21:48 +00:00
2013-11-25 18:40:52 +00:00
if ( ! $sniffer . animations ) return ;
2013-11-19 05:21:48 +00:00
2013-11-25 18:40:52 +00:00
$animate . enabled ( true ) ;
2013-11-19 05:21:48 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.cross-animation' , '-webkit-animation:1s my_animation;' +
'animation:1s my_animation;' ) ;
2013-11-19 05:21:48 +00:00
2013-11-25 18:40:52 +00:00
var element = $compile ( '<div class="cross-animation"></div>' ) ( $rootScope ) ;
$rootElement . append ( element ) ;
jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
2013-11-19 05:21:48 +00:00
2013-11-25 18:40:52 +00:00
var node = element [ 0 ] ;
var animationKey = $sniffer . vendorPrefix == 'Webkit' ? 'WebkitAnimation' : 'animation' ;
2013-11-19 05:21:48 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( element , 'trigger-class' ) ;
2013-11-19 05:21:48 +00:00
2013-11-25 18:40:52 +00:00
expect ( node . style [ animationKey ] ) . toContain ( 'none' ) ;
2013-11-19 05:21:48 +00:00
2013-11-25 18:40:52 +00:00
$timeout . flush ( ) ;
2013-11-24 02:44:14 +00:00
2013-11-25 18:40:52 +00:00
expect ( node . style [ animationKey ] ) . not . toContain ( 'none' ) ;
} ) ) ;
2013-12-19 16:56:26 +00:00
2013-11-25 18:40:52 +00:00
it ( 'should block and unblock keyframe animations before the followup JS animation occurs' , function ( ) {
module ( function ( $animateProvider ) {
$animateProvider . register ( '.special' , function ( $sniffer , $window ) {
var prop = $sniffer . vendorPrefix == 'Webkit' ? 'WebkitAnimation' : 'animation' ;
return {
beforeAddClass : function ( element , className , done ) {
expect ( element [ 0 ] . style [ prop ] ) . not . toContain ( 'none' ) ;
expect ( $window . getComputedStyle ( element [ 0 ] ) [ prop + 'Duration' ] ) . toBe ( '1s' ) ;
done ( ) ;
} ,
addClass : function ( element , className , done ) {
expect ( element [ 0 ] . style [ prop ] ) . not . toContain ( 'none' ) ;
expect ( $window . getComputedStyle ( element [ 0 ] ) [ prop + 'Duration' ] ) . toBe ( '1s' ) ;
done ( ) ;
}
2013-11-24 02:44:14 +00:00
}
2013-11-25 18:40:52 +00:00
} ) ;
2013-11-24 02:44:14 +00:00
} ) ;
2013-11-25 18:40:52 +00:00
inject ( function ( $rootScope , $compile , $rootElement , $document , $animate , $sniffer , $timeout , $window ) {
if ( ! $sniffer . animations ) return ;
2013-11-24 02:44:14 +00:00
2013-11-25 18:40:52 +00:00
$animate . enabled ( true ) ;
2013-11-24 02:44:14 +00:00
2013-11-25 18:40:52 +00:00
ss . addRule ( '.special' , '-webkit-animation:1s special_animation;' +
'animation:1s special_animation;' ) ;
2013-11-24 02:44:14 +00:00
2013-11-25 18:40:52 +00:00
var capturedProperty = 'none' ;
2013-11-24 02:44:14 +00:00
2013-11-25 18:40:52 +00:00
var element = $compile ( '<div class="special"></div>' ) ( $rootScope ) ;
$rootElement . append ( element ) ;
jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
2013-11-24 02:44:14 +00:00
2013-11-25 18:40:52 +00:00
$animate . addClass ( element , 'some-klass' ) ;
2013-11-24 02:44:14 +00:00
2013-11-25 18:40:52 +00:00
var prop = $sniffer . vendorPrefix == 'Webkit' ? 'WebkitAnimation' : 'animation' ;
2013-11-24 02:44:14 +00:00
2013-11-25 18:40:52 +00:00
expect ( element [ 0 ] . style [ prop ] ) . toContain ( 'none' ) ;
expect ( $window . getComputedStyle ( element [ 0 ] ) [ prop + 'Duration' ] ) . toBe ( '0s' ) ;
2013-11-24 02:44:14 +00:00
2013-11-25 18:40:52 +00:00
$timeout . flush ( ) ;
} ) ;
2013-11-24 02:44:14 +00:00
} ) ;
2013-11-28 04:18:51 +00:00
2013-12-19 16:56:26 +00:00
2013-11-28 04:18:51 +00:00
it ( 'should round up long elapsedTime values to close off a CSS3 animation' ,
inject ( function ( $rootScope , $compile , $rootElement , $document , $animate , $sniffer , $timeout , $window ) {
if ( ! $sniffer . animations ) return ;
ss . addRule ( '.millisecond-transition.ng-leave' , '-webkit-transition:510ms linear all;' +
'transition:510ms linear all;' ) ;
var element = $compile ( '<div class="millisecond-transition"></div>' ) ( $rootScope ) ;
$rootElement . append ( element ) ;
jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
$animate . leave ( element ) ;
$rootScope . $digest ( ) ;
$timeout . flush ( ) ;
browserTrigger ( element , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 0.50999999991 } ) ;
expect ( $rootElement . children ( ) . length ) . toBe ( 0 ) ;
} ) ) ;
2013-12-04 17:49:02 +00:00
2013-12-19 16:56:26 +00:00
2013-12-04 17:49:02 +00:00
it ( 'should properly animate elements with compound directives' , function ( ) {
var capturedAnimation ;
module ( function ( $animateProvider ) {
$animateProvider . register ( '.special' , function ( ) {
return {
enter : function ( element , done ) {
capturedAnimation = 'enter' ;
done ( ) ;
} ,
leave : function ( element , done ) {
capturedAnimation = 'leave' ;
done ( ) ;
}
}
} ) ;
} ) ;
inject ( function ( $rootScope , $compile , $rootElement , $document , $timeout , $templateCache , $sniffer ) {
if ( ! $sniffer . transitions ) return ;
$templateCache . put ( 'item-template' , 'item: #{{ item }} ' ) ;
var element = $compile ( '<div>' +
' <div ng-repeat="item in items"' +
' ng-include="tpl"' +
' class="special"></div>' +
'</div>' ) ( $rootScope ) ;
ss . addRule ( '.special' , '-webkit-transition:1s linear all;' +
'transition:1s linear all;' ) ;
$rootElement . append ( element ) ;
jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
$rootScope . tpl = 'item-template' ;
$rootScope . items = [ 1 , 2 , 3 ] ;
$rootScope . $digest ( ) ;
$timeout . flush ( ) ;
expect ( capturedAnimation ) . toBe ( 'enter' ) ;
expect ( element . text ( ) ) . toContain ( 'item: #1' ) ;
forEach ( element . children ( ) , function ( kid ) {
browserTrigger ( kid , 'transitionend' , { timeStamp : Date . now ( ) + 1000 , elapsedTime : 1 } ) ;
} ) ;
$timeout . flush ( ) ;
$rootScope . items = [ ] ;
$rootScope . $digest ( ) ;
$timeout . flush ( ) ;
expect ( capturedAnimation ) . toBe ( 'leave' ) ;
} ) ;
} ) ;
2013-12-16 20:45:57 +00:00
it ( 'should animate only the specified CSS className' , function ( ) {
var captures = { } ;
module ( function ( $animateProvider ) {
$animateProvider . classNameFilter ( /prefixed-animation/ ) ;
$animateProvider . register ( '.capture' , function ( ) {
return {
enter : buildFn ( 'enter' ) ,
leave : buildFn ( 'leave' )
} ;
function buildFn ( key ) {
return function ( element , className , done ) {
captures [ key ] = true ;
( done || className ) ( ) ;
}
}
} ) ;
} ) ;
inject ( function ( $rootScope , $compile , $rootElement , $document , $timeout , $templateCache , $sniffer , $animate ) {
if ( ! $sniffer . transitions ) return ;
var element = $compile ( '<div class="capture"></div>' ) ( $rootScope ) ;
$rootElement . append ( element ) ;
jqLite ( $document [ 0 ] . body ) . append ( $rootElement ) ;
var enterDone = false ;
$animate . enter ( element , $rootElement , null , function ( ) {
enterDone = true ;
} ) ;
$rootScope . $digest ( ) ;
$timeout . flush ( ) ;
expect ( captures [ 'enter' ] ) . toBeUndefined ( ) ;
expect ( enterDone ) . toBe ( true ) ;
element . addClass ( 'prefixed-animation' ) ;
var leaveDone = false ;
$animate . leave ( element , function ( ) {
leaveDone = true ;
} ) ;
$rootScope . $digest ( ) ;
$timeout . flush ( ) ;
expect ( captures [ 'leave' ] ) . toBe ( true ) ;
expect ( leaveDone ) . toBe ( true ) ;
} ) ;
} ) ;
2013-11-24 02:44:14 +00:00
} ) ;
feat(ngAnimate): complete rewrite of animations
- ngAnimate directive is gone and was replaced with class based animations/transitions
- support for triggering animations on css class additions and removals
- done callback was added to all animation apis
- $animation and $animator where merged into a single $animate service with api:
- $animate.enter(element, parent, after, done);
- $animate.leave(element, done);
- $animate.move(element, parent, after, done);
- $animate.addClass(element, className, done);
- $animate.removeClass(element, className, done);
BREAKING CHANGE: too many things changed, we'll write up a separate doc with migration instructions
2013-06-18 17:59:57 +00:00
} ) ;