Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
137
rated 0 times [  139] [ 2]  / answers: 1 / hits: 16839  / 7 Years ago, thu, february 23, 2017, 12:00:00

I am trying to create some transitions on my router-view components every time I click a new link. The problem is that only one of the fade animations will work. For example, it will fade out, but the new page will appear immediately like normal. Basically I can only have either an enter-active-class or a leave-active-class, but not both at the same time.



<template>

<div class=tom-layout>
<navBar class=z-depth-0></navBar>
<div class=content-layout>
<transition name=fade>
<router-view></router-view>
</transition>
</div>
</div>

</template>

<script>
import NavBar from './components/NavBar.vue';

export default {
components: {
navBar: NavBar
}
}

</script>

<style lang=scss>
@import url('https://fonts.googleapis.com/css?family=Ek+Mukta');

body {

overflow: hidden;

.content-layout {
margin-top: -64px;
width: 100%;
z-index: -5;
}
}


.fade-enter {
opacity: 0;
}

.fade-enter-active {
transition: opacity 2s ease;
}

.fade-leave {

}

.fade-leave-active {
transition: opacity 2s ease;
opacity: 0;
}

More From » css

 Answers
299

I am just using mode: out-in it seems to working fine with:


  <transition name="fade" mode="out-in">
<router-view></router-view>
</transition>

Please check working fiddle.


[#58805] Tuesday, February 21, 2017, 7 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
louiseb

Total Points: 368
Total Questions: 107
Total Answers: 107

Location: Tanzania
Member since Wed, Feb 24, 2021
3 Years ago
;