From e09a505ce5a6643a9f71886ad22fec2eb944edbb Mon Sep 17 00:00:00 2001 From: Jordan Eldredge Date: Thu, 21 Mar 2019 19:05:20 -0700 Subject: [PATCH] Don't render visualizer background when disabled Fixes https://github.com/captbaritone/webamp/issues/762 --- js/components/Visualizer.js | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/js/components/Visualizer.js b/js/components/Visualizer.js index 30a804a5..b4413761 100644 --- a/js/components/Visualizer.js +++ b/js/components/Visualizer.js @@ -176,10 +176,6 @@ class Visualizer extends React.Component { } } - clear() { - this.canvasCtx.drawImage(this.bgCanvas, 0, 0); - } - // Pre-render the background grid preRenderBg() { this.bgCanvas = preRenderBg( @@ -201,11 +197,17 @@ class Visualizer extends React.Component { } paintFrame() { - this.clear(); - if (this.props.style === VISUALIZERS.OSCILLOSCOPE) { - this._paintOscilloscopeFrame(); - } else if (this.props.style === VISUALIZERS.BAR) { - this._paintBarFrame(); + switch (this.props.style) { + case VISUALIZERS.OSCILLOSCOPE: + this.canvasCtx.drawImage(this.bgCanvas, 0, 0); + this._paintOscilloscopeFrame(); + break; + case VISUALIZERS.BAR: + this.canvasCtx.drawImage(this.bgCanvas, 0, 0); + this._paintBarFrame(); + break; + default: + this.canvasCtx.clearRect(0, 0, this.canvas.width, this.canvas.height); } }