From bf170beffab2ec9aedbcaa981b9e5cece8ba287f Mon Sep 17 00:00:00 2001 From: dsavvinov Date: Thu, 1 Sep 2016 10:59:16 +0300 Subject: [PATCH] UI: fixed bug when coordinates tooltip didn't take into account window scrolls. Fixed bug when some items on canvas could be lost after resizing --- ui/scripts/algorithms/perimeter.js | 2 +- ui/scripts/index.js | 2 +- ui/scripts/util/drawing.js | 7 ++++++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/ui/scripts/algorithms/perimeter.js b/ui/scripts/algorithms/perimeter.js index 19a6e5eb6f2..d7d242d56b3 100644 --- a/ui/scripts/algorithms/perimeter.js +++ b/ui/scripts/algorithms/perimeter.js @@ -26,7 +26,7 @@ function perimeterDebugRequest() { console.log("Got debug response"); var debugInfo = DebugResponse.decode64(data); console.log("Drawing"); - drawDebug(debugInfo); + drawDebug(debugInfo, 1); }); } diff --git a/ui/scripts/index.js b/ui/scripts/index.js index c75f7537ff4..98b8b414f39 100644 --- a/ui/scripts/index.js +++ b/ui/scripts/index.js @@ -137,7 +137,7 @@ function init() { var mousePos = getMousePos(evt); var message = "(" + mousePos.x + "," + mousePos.y + ")"; tooltip[0].textContent = message; - tooltip.offset( {top: (evt.clientY + 20), left: (evt.clientX + 20) } ); + tooltip.offset( {top: (evt.pageY + 20), left: (evt.pageX + 20) } ); }, false ); diff --git a/ui/scripts/util/drawing.js b/ui/scripts/util/drawing.js index 8cb1eb42ce1..3c2ebfbb90b 100644 --- a/ui/scripts/util/drawing.js +++ b/ui/scripts/util/drawing.js @@ -213,7 +213,7 @@ function drawAxis() { drawLine(createLine(0, 1, 0), "black", 2) } -function drawDebug(data) { +function drawDebug(data, attempt) { ctx.clearRect(0, 0, canvas.width, canvas.height); var segments = []; @@ -247,4 +247,9 @@ function drawDebug(data) { } drawAxis() + + // re-draw everything to be sure that all resizing and centering will take their place + if (attempt == 1) { + drawDebug(data, 0) + } }