Hide and remove uneeded canvas object generated for the player background

This commit is contained in:
Eliot Berriot 2019-01-15 09:57:20 +01:00
parent 9fd52afe56
commit df01f62b01
No known key found for this signature in database
GPG Key ID: DD6965E2476E5C27
3 changed files with 8 additions and 0 deletions

View File

@ -221,6 +221,7 @@ import { mapState, mapGetters, mapActions } from "vuex"
import GlobalEvents from "@/components/utils/global-events"
import ColorThief from "@/vendor/color-thief"
import { Howl } from "howler"
import $ from 'jquery'
import AudioTrack from "@/components/audio/Track"
import TrackFavoriteIcon from "@/components/favorites/TrackFavoriteIcon"
@ -310,6 +311,8 @@ export default {
this.$refs.currentAudio.setCurrentTime(time)
},
updateBackground() {
// delete existing canvas, if any
$('canvas.color-thief').remove()
if (!this.currentTrack.album.cover) {
this.ambiantColors = this.defaultAmbiantColors
return

View File

@ -263,3 +263,7 @@ button.reset {
label .tooltip {
margin-left: 1em;
}
canvas.color-thief {
display: none;
}

View File

@ -27,6 +27,7 @@
*/
var CanvasImage = function (image) {
this.canvas = document.createElement('canvas');
this.canvas.className = "color-thief hidden";
this.context = this.canvas.getContext('2d');
document.body.appendChild(this.canvas);