From c5ede4cc69078a5f4dbaab0b58d79c1d50565524 Mon Sep 17 00:00:00 2001 From: Nicola <47360416+unsettledgames@users.noreply.github.com> Date: Mon, 31 Jan 2022 23:17:15 +0100 Subject: [PATCH] Fixed selection tools dragging when the cursor is not in the selection --- js/tools/EllipseTool.js | 3 --- js/tools/LassoSelectionTool.js | 3 --- js/tools/MoveSelectionTool.js | 3 +++ js/tools/RectangleTool.js | 2 -- js/tools/ResizableTool.js | 1 + 5 files changed, 4 insertions(+), 8 deletions(-) diff --git a/js/tools/EllipseTool.js b/js/tools/EllipseTool.js index fc98eff..68fb4c9 100644 --- a/js/tools/EllipseTool.js +++ b/js/tools/EllipseTool.js @@ -1,6 +1,3 @@ -/** TODO - * - Increase the sensibility of the tool depending on the width / height ratio to avoid holes - */ class EllipseTool extends ResizableTool { // Saving the empty rect svg emptyEllipseSVG = document.getElementById("ellipse-empty-button-svg"); diff --git a/js/tools/LassoSelectionTool.js b/js/tools/LassoSelectionTool.js index 9be1f6e..fb0ac7a 100644 --- a/js/tools/LassoSelectionTool.js +++ b/js/tools/LassoSelectionTool.js @@ -1,6 +1,3 @@ -/** TODO - * - Move the selection only if the user started dragging inside of it - */ class LassoSelectionTool extends SelectionTool { currentPixels = []; diff --git a/js/tools/MoveSelectionTool.js b/js/tools/MoveSelectionTool.js index 9dd35e9..32f0bad 100644 --- a/js/tools/MoveSelectionTool.js +++ b/js/tools/MoveSelectionTool.js @@ -75,6 +75,9 @@ class MoveSelectionTool extends DrawingTool { onDrag(mousePos) { super.onDrag(mousePos); + + if (!this.selectionTool.cursorInSelectedArea(mousePos)) + return; this.selectionTool.moveOffset = [Math.floor(mousePos[0] / currFile.zoom - currFile.canvasSize[0] / 2 - (this.selectionTool.boundingBoxCenter[0] - currFile.canvasSize[0]/2)), diff --git a/js/tools/RectangleTool.js b/js/tools/RectangleTool.js index 25bb8f4..7ecd78a 100644 --- a/js/tools/RectangleTool.js +++ b/js/tools/RectangleTool.js @@ -1,5 +1,3 @@ -// TODO: FIX SELECTION - class RectangleTool extends ResizableTool { // Saving the empty rect svg emptyRectangleSVG = document.getElementById("rectangle-empty-button-svg"); diff --git a/js/tools/ResizableTool.js b/js/tools/ResizableTool.js index 8bcb5a7..890b7f2 100644 --- a/js/tools/ResizableTool.js +++ b/js/tools/ResizableTool.js @@ -47,6 +47,7 @@ class ResizableTool extends DrawingTool { //fix offset so the cursor stays centered this.updateCursor(); this.onHover(this.startResizePos, mouseEvent); + TopMenuModule.updateField(this.name + "-input", this.currSize); } onRightEnd(mousePos, mouseEvent) {