Skip to content

Instantly share code, notes, and snippets.

@johnpapa
Created August 31, 2016 04:20
Show Gist options
  • Save johnpapa/c38ffacdf421a437b4cd4d52280be244 to your computer and use it in GitHub Desktop.
Save johnpapa/c38ffacdf421a437b4cd4d52280be244 to your computer and use it in GitHub Desktop.
Angular 2 Component Animation
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