Search code examples
vue.jsvuejs2transitionvuetify.js

Vuetify transitions: How to set the transition speed


I have an <audioplayer> component that I would like to be displayed slowly sliding from the bottom of a parent component.

I defined it inside <v-slide-y-transition>, but how I can make it slide slowly from the bottom? I cannot find any attributes to be defined for the <v-slide-y-transition> Vuetify component.

<v-parallax src="img/hero.jpeg">
  <v-layout column align-center justify-center>
    <img src="@/assets/images/logo.png" height="200">
    <h1 class="mb-2 display-1 text-xs-center">HEADER 1</h1>
    <h2 class="mb-2 display-1 text-xs-center">HEADER 2</h2>
    <div class="subheading mb-3 text-xs-center">SUB-HEADER</div>
    <v-btn round @click="switchAudioPlayer()" large href="#">LISTEN</v-btn>
    <v-slide-y-transition>
      <audioplayer id="audioplayer" v-if="listening" v-show="showAudioPlayer" :autoPlay="autoPlay" :file="audioFile" :canPlay="audioReady" :ended="switchAudioPlayer"></audioplayer>
    </v-slide-y-transition>
 </v-layout>
</v-parallax>

Solution

  • Vuetify transitions don't appear to have configuration properties, so you'd have to create your own in order to tweak the timing.

    You could use a Vue <transition> component, using CSS transition property to set the timing of the animation.

    For example, the following CSS sets the duration of the slide-fade animation to 2 seconds.

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

    Demo:

    new Vue({
      el: '#app',
      data: () => ({
        show: false,
      }),
    })
    .slide-fade-enter-active {
      transition: all 2s 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 below version 2.1.8 */ {
      transform: translateY(30px);
      opacity: 0;
    }
    
    footer {
      position: absolute;
      bottom: 0;
    }
    <script src="https://unpkg.com/[email protected]"></script>
    
    <div id="app">
      <button v-on:click="show = !show">
        Toggle
      </button>
      <footer>
        <transition name="slide-fade">
          <p v-if="show">hello</p>
        </transition>
      </footer>
    </div>