Skip to content

Instantly share code, notes, and snippets.

@TravisMullen
Last active January 16, 2017 21:11
Show Gist options
  • Save TravisMullen/2bc1cb2bddb030a80d4e3b03839a2a78 to your computer and use it in GitHub Desktop.
Save TravisMullen/2bc1cb2bddb030a80d4e3b03839a2a78 to your computer and use it in GitHub Desktop.
Watcher for $animateCss (Angular 1.5)
'use strict';
// for use of 100% CSS but still want that angular layer
//
// assumes standard ngAnimate CSS class usage `ng-EVENT`
//
// .animation-watcher {
// /* this transition tells ngAnimate to make the animation happen */
// transition-property: all;
// transition-duration: 3s;
// transition-timing-function: cubic-bezier(0.940, 0.460, 0.450, 0.250);
// &.ng-enter-prepare {
// }
// &.ng-enter,
// &.ng-leave.ng-leave-active {
// }
// &.ng-leave,
// &.ng-enter.ng-enter-active {
// }
// }
angular.module( 'animations.watcher', ['ngAnimate'] )
.animation( '.animation-watcher', [ '$animateCss', function( $animateCss ) {
return {
enter : function( element, done ) {
var animation = $animateCss( element, {
event : 'enter',
cleanupStyles : true,
structural : true,
delay : true
});
console.log( 'animation-watcher enter start' );
animation.start().done( function( res ) {
console.log( 'animation-watcher enter done!', res );
done();
});
},
leave : function( element, done ) {
// todo: if running, queue this next in line and wait for complete
//
var animation = $animateCss( element, {
event : 'leave',
cleanupStyles : true,
structural : true,
delay : true
});
console.log( 'animation-watcher leave start' );
animation.start().done( function( res ) {
console.log( 'animation-watcher leave done!', res );
done();
});
}
}
} ] );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment