hide player when queue is empty

This commit is contained in:
Thomas Amland 2020-09-25 19:37:24 +02:00
parent 45fc4eb69f
commit d025c0aae5
2 changed files with 16 additions and 12 deletions

View File

@ -8,9 +8,7 @@
</main> </main>
</div> </div>
<ErrorBar /> <ErrorBar />
<footer class="footer elevated"> <Player />
<Player />
</footer>
</div> </div>
</template> </template>
<style lang="scss"> <style lang="scss">
@ -18,13 +16,7 @@
margin-bottom: 80px; margin-bottom: 80px;
overflow-x: hidden; overflow-x: hidden;
} }
.footer {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 80px;
}
</style> </style>
<script lang="ts"> <script lang="ts">
import ErrorBar from './ErrorBar.vue' import ErrorBar from './ErrorBar.vue'

View File

@ -1,5 +1,5 @@
<template> <template>
<div class="d-flex player"> <div :class="{'visible': visible}" class="player elevated d-flex">
<div v-if="track" class="d-none d-sm-block"> <div v-if="track" class="d-none d-sm-block">
<router-link :to="track.albumId ? {name: 'album', params: {id: track.albumId}} : ''"> <router-link :to="track.albumId ? {name: 'album', params: {id: track.albumId}} : ''">
<img v-if="track.image" width="80px" height="80px" :src="track.image"> <img v-if="track.image" width="80px" height="80px" :src="track.image">
@ -49,6 +49,17 @@
.progress2 { .progress2 {
cursor: pointer; cursor: pointer;
} }
.player {
position: fixed;
bottom: 0;
left: 0;
right: 0;
height: 0;
transition: 0.5s
}
.visible {
height: 80px;
}
</style> </style>
<script lang="ts"> <script lang="ts">
import Vue from 'vue' import Vue from 'vue'
@ -65,6 +76,7 @@
isPlaying: (state: any) => state.isPlaying, isPlaying: (state: any) => state.isPlaying,
currentTime: (state: any) => state.currentTime, currentTime: (state: any) => state.currentTime,
duration: (state: any) => state.duration, duration: (state: any) => state.duration,
visible: (state: any) => state.queue.length > 0,
}), }),
...mapGetters('player', [ ...mapGetters('player', [
'track', 'track',
@ -83,7 +95,7 @@
const value = event.offsetX / width const value = event.offsetX / width
return this.$store.dispatch('player/seek', value) return this.$store.dispatch('player/seek', value)
} }
} },
} }
}) })
</script> </script>