From d4de08e8bec4a847edbb34e048e8b832455eb4da Mon Sep 17 00:00:00 2001 From: Jascha Bakarinow Date: Sat, 17 Jul 2021 22:55:51 +0200 Subject: [PATCH] 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