Skip to content
Advertisement

VueJS – Transition not working

I’m trying to apply a transition whether a component has to be shown or not. I’m wondering why this simple example is not working: http://jsfiddle.net/bf830qoq/

Javascript

Vue.component('loading', {
  template: '#loading-template',
});

new Vue({
  el: '#app',
  data: {
    showLoging: false
  }
});

HTML

<script type="x/template" id="loading-template">
    <transition="slide-fade">
    <div>Loading</div>
    </transition>
</script>

<!-- app -->
<div id="app">
    <loading v-if='showLoging'></loading>
    <button id="show-login" @click="showLoging = !showLoging">Show</button>
</div>

CSS

.slide-fade-enter-active {
  transition: all .3s ease;
}
.slide-fade-leave-active {
  transition: all .8s cubic-bezier(1.0, 0.5, 0.8, 1.0);
}
.slide-fade-enter, .slide-fade-leave-to
/* .slide-fade-leave-active for <2.1.8 */ {
  transform: translateX(10px);
  opacity: 0;
}

Advertisement

Answer

Your syntax is wrong, you have to use name attribute for transition, like following:

<transition name="slide-fade" mode="in-out">
    <div>Loading</div>
</transition>

See working fiddle.

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement