canvas: more safe check before drawing

This commit is contained in:
jean-emmanuel 2025-04-20 15:23:48 +02:00
parent ccba528cbf
commit c092951052
3 changed files with 6 additions and 3 deletions

View file

@ -101,7 +101,10 @@ class Canvas extends Widget {
this.hasSize = true
this.setVisibility()
}
this.draw()
if (this.width > 0 && this.height > 0 && this.visible) {
this.draw()
}
})

View file

@ -390,7 +390,7 @@ class Fader extends Slider {
this.shouldDrawPips = false
}
if (this.pips) {
if (this.pips && this.pips.width && this.pips.height) {
this.ctx.globalAlpha = 1
this.ctx.drawImage(this.pips, 0, 0)
if (!compact) this.clearRect = [this.clearRect, [m + knobWidth / 2, 0, 12 * PXSCALE + this.pipsTextSize, height]]

View file

@ -389,7 +389,7 @@ class Range extends Fader {
this.shouldDrawPips = false
}
if (this.pips) {
if (this.pips && this.pips.width && this.pips.height) {
this.ctx.globalAlpha = 1
this.ctx.drawImage(this.pips, 0, 0)
if (!compact) this.clearRect = [this.clearRect, [m + knobWidth / 2, 0, 12 * PXSCALE + this.pipsTextSize, height]]