diff --git a/hw3/Claudio_Maggioni/scripts/app.js b/hw3/Claudio_Maggioni/scripts/app.js index 54dace8..087f490 100644 --- a/hw3/Claudio_Maggioni/scripts/app.js +++ b/hw3/Claudio_Maggioni/scripts/app.js @@ -45,10 +45,12 @@ class App { this.canvas.addEventListener('mousemove', (e) => this.mousedown && this.draw(e)); const endPath = (e) => { - this.ctx.lineTo(e.offsetX, e.offsetY); - this.ctx.stroke(); - this.ctx.restore(); - this.mousedown = false; + if (this.mousedown) { + this.ctx.lineTo(e.offsetX, e.offsetY); + this.ctx.stroke(); + this.ctx.restore(); + this.mousedown = false; + } }; this.canvas.addEventListener('mouseup', endPath);