Performance: Animation mixin patterns
MEDIUM IMPACT
Animation mixin patterns affect the browser's paint and composite stages, impacting smoothness and CPU/GPU usage during animations.
@mixin animate-opacity { animation: fadeInOpacity 1s ease-in-out; } .element { @include animate-opacity; will-change: opacity; }
@mixin animate-all { animation: fadeIn 1s ease-in-out; } .element { @include animate-all; transition: all 0.3s ease; }
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Animating 'all' properties via mixin | Multiple style recalculations | Multiple reflows per frame | High paint cost | [X] Bad |
| Animating 'opacity' only with will-change | Minimal style recalculations | No reflows | Low paint cost, GPU compositing | [OK] Good |