I'm trying to do simple fade animation on route change, but it doesn't work.
My animation file it's like this:
export class RouterAnimations {
static animate() {
return trigger('routerTransition', [
state('void', style({ opacity: 0 })),
state('*', style({ opacity: 1 })),
transition(':enter', [
style({ opacity: 0 }),
animate('0.4s ease')
]),
transition(':leave', [
style({ opacity: 1 }),
animate('0.4s ease')
])
]);
};
};
My component's like this:
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['../vitrine.component.css', './home.component.css'],
animations: [RouterAnimations.animate()]
})
export class HomeComponent implements OnInit {
@HostBinding('@routerTransition')
public routerTransition = true;
constructor() { }
ngOnInit() {
}
}
I observed that if I put a position: fixed
on states, it works, but when the animation is completed the view is fixed and the layout is broken in the application.