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

This commit is contained in:
dsavvinov
2016-09-01 10:59:16 +03:00
parent 20c3325208
commit bf170beffa
3 changed files with 8 additions and 3 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ function perimeterDebugRequest() {
console.log("Got debug response");
var debugInfo = DebugResponse.decode64(data);
console.log("Drawing");
drawDebug(debugInfo);
drawDebug(debugInfo, 1);
});
}
+1 -1
View File
@@ -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
);
+6 -1
View File
@@ -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)
}
}