From ef01be33232bb511a5dc9f8605dc4404896efef9 Mon Sep 17 00:00:00 2001 From: Dariusz L Date: Wed, 2 Jul 2025 08:48:41 +0200 Subject: [PATCH] Add canvas move and resize interactions Implemented new interaction modes for moving and resizing the canvas using shift and alt modifiers. Added corresponding handlers for mouse events to support these actions. --- js/CanvasInteractions.js | 27 ++++++++++++++++++++++++++- 1 file changed, 26 insertions(+), 1 deletion(-) diff --git a/js/CanvasInteractions.js b/js/CanvasInteractions.js index 23b8ac0..656626e 100644 --- a/js/CanvasInteractions.js +++ b/js/CanvasInteractions.js @@ -130,7 +130,12 @@ export class CanvasInteractions { case 'rotating': this.rotateLayerFromHandle(worldCoords, e.shiftKey); break; - // ... inne tryby + case 'resizingCanvas': + this.updateCanvasResize(worldCoords); + break; + case 'movingCanvas': + this.updateCanvasMove(worldCoords); + break; default: this.updateCursor(worldCoords); break; @@ -138,6 +143,13 @@ export class CanvasInteractions { } handleMouseUp(e) { + if (this.interaction.mode === 'resizingCanvas') { + this.finalizeCanvasResize(); + } + if (this.interaction.mode === 'movingCanvas') { + this.finalizeCanvasMove(); + } + // Zapisz stan tylko, jeśli faktycznie doszło do zmiany (przeciąganie, transformacja, duplikacja) const stateChangingInteraction = ['dragging', 'resizing', 'rotating'].includes(this.interaction.mode); const duplicatedInDrag = this.interaction.hasClonedInDrag; @@ -381,6 +393,19 @@ export class CanvasInteractions { } startPanningOrClearSelection(e) { + const worldCoords = this.canvas.getMouseWorldCoordinates(e); + + // Sprawdź modyfikatory dla akcji na tle + if (e.shiftKey) { + this.startCanvasResize(worldCoords); + return; + } + if (e.altKey) { + this.startCanvasMove(worldCoords); + return; + } + + // Domyślna akcja: wyczyść zaznaczenie i rozpocznij panoramowanie if (!this.interaction.isCtrlPressed) { this.canvas.updateSelection([]); }