1👍
✅
The <transition>
effects will only work for elements that change their visibility. So for example by using v-if
.
So you have two options.
- Either add a
v-if
logic to your template.
For example: (a quick mock up. could be refactored to be cleaner)
<div id="app">
<button type="button" @click="toggle">
Toggle
</button>
<transition name="fade">
<div
v-if="isFullScreen"
v-bind:class="{
'fullscreen':isFullScreen,
'regularSize':!isFullScreen
}">
<p>FULL SCREEN</p>
<button type="button" @click="toggle">
Toggle
</button>
</div>
</transition>
<transition name="fade">
<div
v-if="!isFullScreen"
v-bind:class="{
'fullscreen':isFullScreen,
'regularSize':!isFullScreen
}">
<p>SMALL SCREEN</p>
</div>
</transition>
</div>
- Create the transition effect purely with css.
Source:stackexchange.com