Performance: Transition modes (in-out, out-in)
This affects the smoothness and timing of element transitions, impacting rendering speed and visual stability during animations.
<transition mode="out-in"> <component :is="currentComponent" /> </transition>
<transition>
<component :is="currentComponent" />
</transition>| Pattern | DOM Operations | Reflows | Paint Cost | Verdict |
|---|---|---|---|---|
| Default mode (simultaneous) | 2 element changes | 2 reflows (enter + leave) | High paint cost due to layout thrashing | [X] Bad |
| out-in mode (leave then enter) | 2 element changes | 1 reflow (sequential) | Lower paint cost, smoother transition | [OK] Good |
| in-out mode (enter then leave) | 2 element changes | 1 reflow (sequential) | Lower paint cost, better perceived responsiveness | [OK] Good |
in-out transition mode do in Vue transitions?in-out behaviorin-out means the new element enters first, then the old element leaves.out-in transition mode in a Vue <transition> component?mode attribute on <transition> sets the transition mode.<transition mode="out-in"> <component :is="view" /> </transition>
view changes from "A" to "B", what happens first?view changes, component A leaves first, then component B enters.<transition mode="in-out"> <div v-if="show">Hello</div> </transition>
out-in mode makes the old element leave first, then the new enters, matching the requirement.Pass the test and this pattern moves unknown