mirror of
https://github.com/Azornes/Comfyui-LayerForge.git
synced 2026-03-21 20:52:12 -03:00
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:
@@ -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([]);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user