mirror of
https://github.com/lospec/pixel-editor.git
synced 2023-08-10 21:12:51 +03:00
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:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user