I have 2 routes:
export const appRoutes: Route[] = [
{
path: 'page1',
component: Page1Component,
data: {
animation: 'page1'
}
},
{
path: 'page2',
component: Page2Component,
data: {
animation: 'page2'
}
},
];
My route animation:
export const routeStateTrigger = trigger('routeState', [
transition('* => *', [
query(':enter', [
style({ position: 'absolute', opacity: 0 })
], { optional: true }),
query(':leave', [
animate(300, style({ opacity: 0 }))
], { optional: true }),
query(':enter', [
style({ position: 'relative', opacity: 0 }),
animate(300, style({ display: 'visible', opacity: 1 }))
], { optional: true })
])
]);
My router:
<div [@routeState]="getAnimationData(routerOutlet)">
<router-outlet #routerOutlet="outlet"></router-outlet>
</div>
and getAnimationData method:
getAnimationData(routerOutlet: RouterOutlet) {
const routeData = routerOutlet.activatedRouteData['animation'];
return routeData ? routeData : 'rootPage';
}
This works well, except for the page transition occurs in two stages (sequential):
- page1 disappears (300 ms)
- AND THEN page2 appears (300 ms)
I want the disappearance of page1 to occur simultaneously with the appearance of page2, the transitions must occur simultaneously.
Problem:
I want to prevent the TEMPORARY EXPLOSION of the contents of page1 or page2.
Explanation:
When an animation with a group (), to make them appear, disappears at the same time. And, temporarily setting the position to “absolute”, the content changes (because the content is 100% wide, and when the container is resized, the content also changes).
z-index:
position: 'relative', 'z-index': 1
, , .
?