From d4de08e8bec4a847edbb34e048e8b832455eb4da Mon Sep 17 00:00:00 2001 From: Jascha Bakarinow Date: Sat, 17 Jul 2021 22:55:51 +0200 Subject: [PATCH 1/3] Move brushPreview when panning with mousewheel --- js/_mouseEvents.js | 3 +++ js/_tools.js | 4 ++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/js/_mouseEvents.js b/js/_mouseEvents.js index 82c5853..fce955c 100644 --- a/js/_mouseEvents.js +++ b/js/_mouseEvents.js @@ -38,6 +38,7 @@ window.addEventListener("mousedown", function (mouseEvent) { } else if (mouseEvent.which == 2) { currentTool = tool.pan; + tool.pan.brushSize = currentToolTemp.brushSize; } else if (currentTool.name == 'pencil' && mouseEvent.which == 3) { currentTool = tool.resizebrush; @@ -171,6 +172,8 @@ window.addEventListener("mouseup", function (mouseEvent) { currentTool = currentToolTemp; currentTool.updateCursor(); + var cursorLocation = getCursorPosition(mouseEvent); + currentTool.moveBrushPreview(cursorLocation); }, false); diff --git a/js/_tools.js b/js/_tools.js index a6d374d..08cb3b6 100644 --- a/js/_tools.js +++ b/js/_tools.js @@ -18,10 +18,10 @@ class Tool { if (options.imageCursor) this.cursor = "url(\'/pixel-editor/"+options.imageCursor+".png\'), auto"; + this.currentBrushSize = 1; + this.previousBrushSize = 1; if (options.brushPreview) { this.brushPreview = true; - this.currentBrushSize = 1; - this.previousBrushSize = 1; } //add to tool object so it can be referenced From f240e54bb320fae0bcef40edb40ccf7a1c742a26 Mon Sep 17 00:00:00 2001 From: Jascha Bakarinow Date: Sat, 17 Jul 2021 23:07:57 +0200 Subject: [PATCH 2/3] Set brushSize before panning with Mousewheel --- js/_mouseEvents.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/js/_mouseEvents.js b/js/_mouseEvents.js index fce955c..c4b4969 100644 --- a/js/_mouseEvents.js +++ b/js/_mouseEvents.js @@ -37,8 +37,8 @@ window.addEventListener("mousedown", function (mouseEvent) { } } else if (mouseEvent.which == 2) { + tool.pan.brushSize = currentTool.brushSize; currentTool = tool.pan; - tool.pan.brushSize = currentToolTemp.brushSize; } else if (currentTool.name == 'pencil' && mouseEvent.which == 3) { currentTool = tool.resizebrush; From e0f64c97ba71da50056f9e9fb370558fa7644f45 Mon Sep 17 00:00:00 2001 From: Jascha Bakarinow Date: Wed, 21 Jul 2021 23:23:31 +0200 Subject: [PATCH 3/3] Fix brushPreview lagging behind --- js/_mouseEvents.js | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/js/_mouseEvents.js b/js/_mouseEvents.js index c4b4969..478dce3 100644 --- a/js/_mouseEvents.js +++ b/js/_mouseEvents.js @@ -217,8 +217,6 @@ function draw (mouseEvent) { //if a document hasnt yet been created or the current layer is locked, exit this function if (!documentCreated || dialogueOpen || !currentLayer.isVisible || currentLayer.isLocked) return; - // Moving brush preview - currentTool.moveBrushPreview(cursorLocation); // Hiding eyedropper, will be shown if it's needed eyedropperPreview.style.display = 'none'; @@ -307,6 +305,9 @@ function draw (mouseEvent) { for (let i=1; i