0
0
Vueframework~8 mins

Transition modes (in-out, out-in) in Vue - Performance & Optimization

Choose your learning style9 modes available
Performance: Transition modes (in-out, out-in)
MEDIUM IMPACT
This affects the smoothness and timing of element transitions, impacting rendering speed and visual stability during animations.
Animating element replacement with smooth transitions
Vue
<transition mode="out-in">
  <component :is="currentComponent" />
</transition>
Waits for leave animation to finish before entering new element, reducing layout thrashing and visual jumps.
📈 Performance Gainsingle reflow per transition, reduces CLS significantly
Animating element replacement with smooth transitions
Vue
<transition>
  <component :is="currentComponent" />
</transition>
Default mode triggers simultaneous enter and leave animations causing layout thrashing and visual jumps.
📉 Performance Costtriggers multiple reflows and layout shifts, increasing CLS
Performance Comparison
PatternDOM OperationsReflowsPaint CostVerdict
Default mode (simultaneous)2 element changes2 reflows (enter + leave)High paint cost due to layout thrashing[X] Bad
out-in mode (leave then enter)2 element changes1 reflow (sequential)Lower paint cost, smoother transition[OK] Good
in-out mode (enter then leave)2 element changes1 reflow (sequential)Lower paint cost, better perceived responsiveness[OK] Good
Rendering Pipeline
Transition modes control the timing of element insertion and removal, affecting layout recalculations and paint operations during animations.
Layout
Paint
Composite
⚠️ BottleneckLayout due to reflows triggered by simultaneous enter/leave animations
Core Web Vital Affected
CLS
This affects the smoothness and timing of element transitions, impacting rendering speed and visual stability during animations.
Optimization Tips
1Use 'out-in' mode to avoid layout thrashing by sequencing leave before enter.
2Use 'in-out' mode to improve perceived responsiveness by entering new content first.
3Avoid default simultaneous mode for complex element replacements to reduce CLS.
Performance Quiz - 3 Questions
Test your performance knowledge
Which transition mode reduces layout thrashing by waiting for the old element to leave before the new enters?
Ain-out
Bdefault
Cout-in
Dsimultaneous
DevTools: Performance
How to check: Record a performance profile during transition. Look for layout and paint events during enter/leave animations.
What to look for: Multiple layout recalculations and long paint times indicate poor transition mode choice causing layout thrashing.