Performance: Enter and leave transitions
MEDIUM IMPACT
This affects the smoothness and speed of element appearance and disappearance on the page, impacting user interaction responsiveness and visual stability.
<template> <transition name="fade"> <div v-if="show" class="box">Content</div> </transition> </template> <style> .fade-enter-active, .fade-leave-active { transition: opacity 0.5s ease; will-change: opacity; } .fade-enter, .fade-leave-to { opacity: 0; } </style>
<template> <transition name="fade"> <div v-if="show" class="box">Content</div> </transition> </template> <style> .fade-enter-active, .fade-leave-active { transition: all 0.5s ease; } .fade-enter, .fade-leave-to { opacity: 0; height: 0; margin: 0; padding: 0; } </style>
| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Animating 'all' properties including height and margin | Multiple style changes | Multiple reflows per frame | High paint cost due to layout changes | [X] Bad |
| Animating only opacity with will-change hint | Minimal style changes | No reflows | Low paint cost, GPU compositing | [OK] Good |