Performance: Route transition animations
MEDIUM IMPACT
This affects the smoothness and responsiveness of page transitions during route changes, impacting user interaction and visual stability.
import { trigger, transition, style, animate } from '@angular/animations'; @Component({ animations: [ trigger('routeAnimations', [ transition('* <=> *', [ style({ transform: 'translateX(100%)', opacity: 0 }), animate('300ms ease-out', style({ transform: 'translateX(0)', opacity: 1 })) ]) ]) ] }) export class AppComponent {}
import { trigger, transition, style, animate } from '@angular/animations'; @Component({ animations: [ trigger('routeAnimations', [ transition('* <=> *', [ style({ opacity: 0 }), animate('500ms ease-in-out', style({ opacity: 1 })) ]) ]) ] }) export class AppComponent {}
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Opacity animation without transform | Minimal DOM changes | No reflows triggered | High paint cost due to opacity changes | [X] Bad |
| Transform translateX with opacity | Minimal DOM changes | No reflows triggered | Low paint cost, GPU accelerated | [OK] Good |