In my angular app I would like the router transitions be animated: the leaving component should fade-out and after that, the entering component should fade in. Basic stuff I would say :)
So I created this stackblitz (some of the code in there was copied from elsewhere), but my main resource was the Angular Route transition animations
But, as you can see, for some reason the animations doesn't do anything.
Here is my animation code
export const routerTransition = trigger("routeAnimations", [
transition("* => *", [
query(":enter, :leave", style({ position: "fixed", width: "100%" })),
query(":enter", style({ transform: "translateX(100%)" })),
sequence([
query(":leave", animateChild()),
query(":leave", [
style({ opacity: 1 }),
animate(
"1000ms cubic-bezier(.75,-0.48,.26,1.52)",
style({ opacity: 0 })
)
]),
query(":enter", [
style({ transform: "translateX(0)", opacity: 0 }),
animate(
"1000ms cubic-bezier(.75,-0.48,.26,1.52)",
style({ opacity: 1 })
)
]),
query(":enter", animateChild())
])
])
]);
Also, here is the HTML from app.component, because thats the place where I connect the animation with the router
<main [@routeAnimations]="prepareRoute(outlet)">
<router-outlet #outlet="outlet"></router-outlet>
</main>
And the prepareRoute looks like:
prepareRoute(outlet: RouterOutlet) {
return (
outlet && outlet.activatedRouteData && outlet.activatedRouteData.animation
);
}
All according to the docs, so I'm a bit lost here with the animations so any help would be appreciated!