From d2fe8d9f90e7c5aaf8ce8621d9a4e75b129515f3 Mon Sep 17 00:00:00 2001 From: Claudio Maggioni Date: Fri, 4 Oct 2019 17:29:36 +0200 Subject: [PATCH] 2019-10-04 in class --- hw3/Claudio_Maggioni/scripts/app.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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);