I would like to make route transition, but not simple slide out/slide in animations. I am looking for animation like this one on left ( https://cdn.dribbble.com/users/495792/screenshots/3847874/allshots3.gif )
I know how to animate routes that will redraw whole content. But how can I achieve effect of transitioning of one/more component to another (this enlarge /zoom effect on left) with changing route.
I would appreciate any advice or direction where to look for some sample codes.
You should read up on Routable Animations. Check out this blog post by Matias Niemelä (guy responsible for @angular/animations).
new-wave-of-animation-features
TL;DR:
<!-- app.html -->
<div [@routeAnimation]="prepRouteState(routerOutlet)">
<!-- make sure to keep the ="outlet" part -->
<router-outlet #routerOutlet="outlet"></router-outlet>
<div>
// app.ts
@Component({
animations: [
trigger('routeAnimation', [
// no need to animate anything on load
transition(':enter', []),
// but anytime a route changes let's animate!
transition('homePage => supportPage', [
// ... some awesome animation here
]),
// and when we go back home
transition('supportPage => homePage', [
// ... some awesome animation here
])
])
]
})
class AppComponent {
prepRouteState(outlet: any) {
return outlet.activatedRouteData['animation'] || 'firstPage';
}
}
<!-- app-routing.module.ts -->
const ROUTES = [
{ path: '',
component: HomePageComponent,
data: {
animation: 'homePage'
}
},
{ path: 'support',
component: SupportPageComponent,
data: {
animation: 'supportPage'
}
}
]
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With