Performance: Why Angular animations matter
MEDIUM IMPACT
Angular animations affect the smoothness of user interactions and visual stability during page updates.
animations: [trigger('fade', [state('void', style({opacity: 0})), transition(':enter', [animate('300ms ease-in', style({opacity: 1}))])])] // Limit animations to opacity and transform properties only, and throttle simultaneous animations
animations: [trigger('expand', [state('void', style({height: '0px'})), transition(':enter', [animate('500ms ease-in', style({height: '*'}))])])] // Using heavy animations on many elements simultaneously without throttling
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Animating layout properties (width, height, margin) | High - multiple nodes affected | Multiple reflows per frame | High paint cost due to layout changes | [X] Bad |
| Animating opacity and transform only | Low - no layout changes | No reflows triggered | Low paint cost, uses GPU compositing | [OK] Good |