Fixed canvas resizing bug

Every time the user opened the window, the events were rebinded and added multiple times. So every popup added a canvas resizing operation.
This commit is contained in:
Nicola 2022-01-05 17:41:13 +01:00
parent 8ee0214fad
commit d6062c51ad
2 changed files with 8 additions and 3 deletions

View File

@ -3,6 +3,7 @@ class File {
canvasSize = [];
zoom = 7;
canvasView = document.getElementById("canvas-view");
inited = false;
// Layers
layers = [];
@ -34,11 +35,13 @@ class File {
// Start resize data
startData = {width: 0, height:0, widthPercentage: 100, heightPercentage: 100};
// Sprite scaling attributes
openResizeCanvasWindow() {
if (!this.inited) {
this.initResizeCanvasInputs();
this.inited = true;
}
// Initializes the inputs
this.initResizeCanvasInputs();
Dialogue.showDialogue('resize-canvas');
}
@ -151,6 +154,9 @@ class File {
currFile.canvasSize[1] = parseInt(currFile.canvasSize[1]) +
this.rcBorders.top + this.rcBorders.bottom;
console.trace();
console.log(currFile.canvasSize);
// Resize the canvases
for (let i=0; i<currFile.layers.length; i++) {
currFile.layers[i].canvas.width = currFile.canvasSize[0];

View File

@ -36,7 +36,6 @@ const ToolManager = (() => {
}
function onMouseWheel(mouseEvent) {
console.log("MOUSE WHEEL");
if (!EditorState.documentCreated || Dialogue.isOpen())
return;