15

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>
tony19
  • 125,647
  • 18
  • 229
  • 307

3 Answers3

9

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/vue@2.5.17"></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>
tony19
  • 125,647
  • 18
  • 229
  • 307
3

If you use Vue 2.2.0+ the transition component has a duration prop so, it would look like this (if you use the vuetify transition name from your question):

 <transition appear name="slide-y-transition" :duration="{ enter: 500, leave: 800 }>
tony19
  • 125,647
  • 18
  • 229
  • 307
Komi
  • 450
  • 5
  • 14
  • 3
    I've tried this using Vue 2.6.12 but it's not working: `` and also ``. They still animate at the default speed i.e. couple hundred millis – RTF Jan 22 '21 at 10:38
1

Note: I noticed that you could add duration property to vuetify transition components. Its value is in milliseconds. But it's not very accurate, so I use it along with some CSS as below.

new Vue({
  el: '#app',
  vuetify: new Vuetify(),
  data: () => ({
    show: false,
  }),
})
p {
  background: lightgreen;
}

.slide-x-transition-enter-active {
  background-color: #b2fab2;
  transition: background-color 2s, all 2s;
}
.slide-x-transition-enter-to {
  background-color: white;
}
.slide-x-transition-leave-active {
  background-color: white;
  transition: background-color 2s, all 2s;
}
.slide-x-transition-leave-to {
  background-color: #fccece;
}
<link href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/@mdi/font@4.x/css/materialdesignicons.min.css" rel="stylesheet">
  <link href="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.min.css" rel="stylesheet">

<script src="https://cdnjs.cloudflare.com/ajax/libs/vue/2.5.17/vue.js"></script>
<script src="https://cdn.jsdelivr.net/npm/vuetify@2.x/dist/vuetify.js"></script>

<v-app id="app">
  <button v-on:click="show = !show">
    Toggle
  </button>
  <v-slide-x-transition duration="2000">
   <p v-if="show">hello</p>
  </v-slide-x-transition>
</v-app>
Kamga Simo Junior
  • 1,679
  • 2
  • 16
  • 30