Angular 2/4+ Router animation, wait for previous route animation to complete

Viewed 1531

I have the following animation configured on 2 of my routes.

trigger('routeAnimation', [
        transition(':enter', [
            style({ opacity: 0 }),
            animate('1s', style({ backgroundColor: 1 }))
        ]),
        transition(':leave', [
            style({ backgroundColor: 1 }),
            animate('1s', style({ backgroundColor: 0 }))
        ]),
    ]),

They work properly. Both get executed when switching from route A to B. However they execute simultaneously. I would like for the TO route to wait for the FROM route's exit animation to finish before coming in.

I want A to completely fade out before B comes in.

Is that possible? Maybe with lifecycle hooks or something?

1 Answers
Related