I copied a code where the component slides from right or left to center but i don't know how the parameter is used. i dont know of any [direction]: 0
property in CSS
function slideTo(direction) {
const optional = {optional : true}
return [
query(':enter, :leave', [
style({
position: 'absolute',
top:0,
[direction]: 0,
width: '100%'
})
], optional),
query(':enter',[
style({ [direction]: '-100%' })
]),
group([
query(':leave',[
animate('600ms ease-in-out', style({ [direction]: '100%'}))
], optional),
query(':enter', [
animate('600ms ease-in-out', style({ [direction]: '0%'}))
])
])
]
Here's the whole ts file
import {
trigger,
transition,
style,
query,
group,
animateChild,
animate,
keyframes
} from '@angular/animations'
export const slider =
trigger('routeAnimations' , [
transition('* => isRight', slideTo('right') )
]);
function slideTo(direction) {
const optional = {optional : true}
return [
query(':enter, :leave', [
style({
position: 'absolute',
top:0,
[direction]: 0,
width: '100%'
})
], optional),
query(':enter',[
style({ [direction]: '-100%' })
]),
group([
query(':leave',[
animate('600ms ease-in-out', style({ [direction]: '100%'}))
], optional),
query(':enter', [
animate('600ms ease-in-out', style({ [direction]: '0%'}))
])
])
]
}
app.component.html
<main [@routeAnimations]="prepareRoute(outlet)" class="content">
<router-outlet #outlet="outlet"></router-outlet>
</main>
app-routing.module.ts
const routes: Routes = [
{path: 'login', component: LoginComponent},
{path: 'equipment', component: EquipmentComponent, data: {animation: 'isRight'}},
{path: '', component: MainformComponent,canActivate:[AuthGuard]}
];