mode="in-out" in Vue transitions?Consider a Vue component that toggles between two elements with a <transition> wrapper using mode="in-out". What is the behavior of the entering and leaving elements?
<template> <transition name="fade" mode="in-out"> <component :is="currentComponent" :key="currentComponent" /> </transition> </template> <script setup> import { ref } from 'vue' const currentComponent = ref('CompA') // toggling logic omitted </script>
Think about which element Vue waits for before starting the other transition.
In in-out mode, Vue waits for the entering element's transition to finish before starting the leaving element's transition.
mode="out-in" affect Vue transition timing?Given a Vue transition with mode="out-in", what is the sequence of the leaving and entering elements?
<template> <transition name="slide" mode="out-in"> <component :is="currentView" :key="currentView" /> </transition> </template>
Consider which element Vue waits to finish before starting the other.
In out-in mode, Vue waits for the leaving element's transition to finish before starting the entering element's transition.
What error occurs if you set mode="inout" (without the dash) on a Vue <transition> component?
<template> <transition name="fade" mode="inout"> <div v-if="show">Content</div> </transition> </template>
Check Vue's behavior on invalid mode values.
Vue warns about invalid mode values and defaults to no mode, so transitions run simultaneously.
mode="in-out" when toggling components?Given a Vue app toggling between CompA and CompB inside a <transition mode="in-out">, which component is visible first during the transition?
<template> <button @click="toggle">Toggle</button> <transition name="fade" mode="in-out"> <component :is="current" :key="current" /> </transition> </template> <script setup> import { ref } from 'vue' const current = ref('CompA') function toggle() { current.value = current.value === 'CompA' ? 'CompB' : 'CompA' } </script>
Recall the in-out mode behavior for entering and leaving elements.
With in-out, the new component enters first and is visible, then the old component leaves after the enter transition finishes.
out-in transition cause a flicker in this Vue app?In a Vue app using <transition mode="out-in"> to switch views, users notice a flicker (blank space) between transitions. What is the most likely cause?
<template> <transition name="fade" mode="out-in"> <component :is="currentView" :key="currentView" /> </transition> </template> <script setup> import { ref } from 'vue' const currentView = ref('ViewA') // toggling logic omitted </script>
Think about the sequence of element removal and insertion in out-in mode.
In out-in mode, Vue removes the leaving element before mounting the entering element, which can cause a brief empty space (flicker) if transitions or content loading take time.