Created
August 31, 2016 04:20
-
-
Save johnpapa/c38ffacdf421a437b4cd4d52280be244 to your computer and use it in GitHub Desktop.
Angular 2 Component Animation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { ComponentOnInit } from '@angular/core'; | |
import { HostBinding, animate, trigger, state, style, transition } from '@angular/core'; | |
@Component({ | |
templateUrl: 'dashboard.component.html', | |
animations: [ | |
trigger('routeAnimation', [ | |
state('*', | |
style({ | |
opacity: 1, | |
transform: 'translateX(0)' | |
}) | |
), | |
transition('void => *', [ | |
style({ | |
opacity: 0, | |
transform: 'translateX(-100%)' | |
}), | |
animate('0.2s ease-in') | |
]), | |
transition('* => void', [ | |
animate('0.5s ease-out', style({ | |
opacity: 0, | |
transform: 'translateY(100%)' | |
})) | |
]) | |
]) | |
] | |
}) | |
export class DashboardComponent { | |
@HostBinding('@routeAnimation') get routeAnimation() { | |
return true; | |
} | |
@HostBinding('style.display') get display() { | |
return 'block'; | |
} | |
@HostBinding('style.position') get position() { | |
return 'absolute'; | |
} | |
// ... | |
// ... | |
// ... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment