Vue transition appear not working
by skirtle
HTML
<script src="//cdn.jsdelivr.net/npm/[email protected]/velocity.min.js"></script>
<div id="app"></div>
SCSS
.c-expansion-box {
max-width: 300px;
border: 1px solid grey;
.c-expansion-box__header {
cursor: pointer;
}
p {
text-align: left;
}
.c-expansion-box__body__wrap {
overflow: hidden;
height: auto;
}
}
JavaScript
var app = new Vue({
template: `
<div class="c-expansion-box">
<div class="c-expansion-box__header" @click="toggleExpansion">
<h3>Click Me</h3>
</div>
<transition
name="expand"
appear
@leave="leave"
@enter="enter"
@appear="enter"
>
<div class="c-expansion-box__body__wrap" v-show="isShown">
<div class="c-expansion-box__body">
<p>
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem
</p>
</div>
</div>
</transition>
</div>
`,
el: '#app',
data: {
isShown: true,
},
methods:{
toggleExpansion(){
this.isShown = !this.isShown;
},
enter(elm, done) {
this.$nextTick(() => {
/*debugger*/
Velocity(elm, 'slideDown', {
duration: 300,
complete: done,
});
})
//debugger
//debugger
//this.$nextTick(() => {
/*elm.style.height = "auto";
elm.style.visibility = "hidden";
const expandedHeight = getComputedStyle(elm).height;
elm.style.height = 0;
elm.style.transition = "height 300ms"
elm.style.visibility = null;
requestAnimationFrame(() => {
elm.style.height = expandedHeight;
});
//})*/
},
leave(elm, done) {
Velocity(elm, 'slideUp', {
duration: 300,
complete: done,
});
},
}
})