Fixed a few minor bugs

Undoing while selecting caused mess.
Selecting outside the canvas caused empty lines to appear on the canvas.
This commit is contained in:
unsettledgames
2020-04-09 16:48:19 +02:00
parent 4b78e8fee1
commit f92a7f4a46
4 changed files with 74 additions and 44 deletions

View File

@@ -127,7 +127,7 @@ window.addEventListener("mouseup", function (mouseEvent) {
layers[i].copyData(layers[0]);
}
}
else if (currentTool == 'rectselect') {
else if (currentTool == 'rectselect' && isRectSelecting) {
endRectSelection(mouseEvent);
}
else if (currentTool == 'rectangle') {
@@ -143,6 +143,8 @@ window.addEventListener("mouseup", function (mouseEvent) {
}, false);
// OPTIMIZABLE: redundant || mouseEvent.target.className in currentTool ifs
//mouse is moving on canvas
window.addEventListener("mousemove", draw, false);
function draw (mouseEvent) {
@@ -300,13 +302,17 @@ function draw (mouseEvent) {
updateCursor();
}
else if (currentTool == 'rectselect') {
if (dragging && !isRectSelecting) {
if (dragging && !isRectSelecting && mouseEvent.target.className == 'drawingCanvas') {
isRectSelecting = true;
console.log("cominciata selezione su " + mouseEvent.target.className);
startRectSelection(mouseEvent);
}
else if (dragging && isRectSelecting) {
updateRectSelection(mouseEvent);
}
else if (isRectSelecting) {
endRectSelection();
}
}
else if (currentTool == 'moveselection') {
// Updating the cursor (move if inside rect, cross if not)