Skip to content Skip to sidebar Skip to footer

Angular 2/4+ Router Animation, Wait For Previous Route Animation To Complete

I have the following animation configured on 2 of my routes. trigger('routeAnimation', [ transition(':enter', [ style({ opacity: 0 }), animate('1s',

Solution 1:

To wait for the leaving route's animation to finish before the entering route's animation begins:

const fadeIn = [
  query(':leave', style({ opacity:1 })),
  query(':enter', style({ opacity:0 })),
  query(':leave', animate('200ms', style({ opacity:0 }))),
  query(':enter', animate('200ms', style({ opacity:1 })))
]

...

trigger('routerAnimations', [
      transition('route1 => route2', fadeIn)
]

The animations will play in sequence.

(Updated after suggesting to delay the entering route by the duration of the leaving route, leading to a verbose solution)

Post a Comment for "Angular 2/4+ Router Animation, Wait For Previous Route Animation To Complete"