From 20b44d4426f33b6b996ba3f8a74029f33c71cfe9 Mon Sep 17 00:00:00 2001 From: Wellington Gabriel Vicente de Souza <wellingtongabrielvs@gmail.com> Date: Sat, 31 Mar 2018 16:33:50 -0300 Subject: [PATCH] [T3] fix bug with split lines functionality --- T3/lines.js | 42 ++++++++++++++++++++++-------------------- 1 file changed, 22 insertions(+), 20 deletions(-) diff --git a/T3/lines.js b/T3/lines.js index 56131a2..22c1a4c 100644 --- a/T3/lines.js +++ b/T3/lines.js @@ -130,26 +130,28 @@ function handleMouse() { break; } } else if (rightClick) { - if (mouseX >= lines[i].x0 && mouseX <= lines[i].xf) { - lines[lines.length] = new Line(mouseX,mouseY,lines[i].xf,lines[i].yf); - lines[i].xf = mouseX; - lines[i].yf = mouseY; - lines[i].width = Math.abs(lines[i].xf - lines[i].x0); - lines[i].height = Math.abs(lines[i].yf - lines[i].y0); - lines[i].centerX = lines[i].x0 + lines[i].width/2; - lines[i].centerY = lines[i].y0 + lines[i].height/2; - rightClick = 0; - break; - } else if (mouseX < lines[i].x0 && mouseX > lines[i].xf) { - lines[lines.length] = new Line(mouseX,mouseY,lines[i].x0,lines[i].y0); - lines[i].x0 = mouseX; - lines[i].y0 = mouseY; - lines[i].width = Math.abs(lines[i].xf - lines[i].x0); - lines[i].height = Math.abs(lines[i].yf - lines[i].y0); - lines[i].centerX = lines[i].xf + lines[i].width/2; - lines[i].centerY = lines[i].yf + lines[i].height/2; - rightClick = 0; - break; + if ((mouseY >= lines[i].y0 && mouseY <= lines[i].yf) || (mouseY >= lines[i].yf && mouseY <= lines[i].y0)) { + if (mouseX >= lines[i].x0 && mouseX <= lines[i].xf) { + lines[lines.length] = new Line(mouseX,mouseY,lines[i].xf,lines[i].yf); + lines[i].xf = mouseX; + lines[i].yf = mouseY; + lines[i].width = Math.abs(lines[i].xf - lines[i].x0); + lines[i].height = Math.abs(lines[i].yf - lines[i].y0); + lines[i].centerX = lines[i].x0 + lines[i].width/2; + lines[i].centerY = lines[i].y0 + lines[i].height/2; + rightClick = 0; + break; + } else if (mouseX < lines[i].x0 && mouseX > lines[i].xf) { + lines[lines.length] = new Line(mouseX,mouseY,lines[i].x0,lines[i].y0); + lines[i].x0 = mouseX; + lines[i].y0 = mouseY; + lines[i].width = Math.abs(lines[i].xf - lines[i].x0); + lines[i].height = Math.abs(lines[i].yf - lines[i].y0); + lines[i].centerX = lines[i].xf + lines[i].width/2; + lines[i].centerY = lines[i].yf + lines[i].height/2; + rightClick = 0; + break; + } } } } -- GitLab