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.
This commit is contained in:
Dariusz L
2025-07-02 08:48:41 +02:00
parent b3d1206f3f
commit ef01be3323

View File

@@ -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([]);
}