mirror of
https://github.com/invoke-ai/InvokeAI
synced 2024-08-30 20:32:17 +00:00
feat(ui): rotation snap to nearest 45deg when holding shift
This commit is contained in:
parent
81bf52ef37
commit
402f5a4717
@ -126,6 +126,15 @@ export class CanvasLayer extends CanvasEntity {
|
||||
return { x: scaledTargetX, y: scaledTargetY };
|
||||
});
|
||||
|
||||
this.konva.transformer.boundBoxFunc((oldBoundBox, newBoundBox) => {
|
||||
if (this._manager.stateApi.getShiftKey()) {
|
||||
if (Math.abs(newBoundBox.rotation % (Math.PI / 4)) > 0) {
|
||||
return oldBoundBox;
|
||||
}
|
||||
}
|
||||
return newBoundBox;
|
||||
});
|
||||
|
||||
this.konva.transformer.on('transformstart', () => {
|
||||
this._log.trace(
|
||||
{
|
||||
@ -249,6 +258,11 @@ export class CanvasLayer extends CanvasEntity {
|
||||
this.isTransforming = false;
|
||||
this._isFirstRender = true;
|
||||
this.isPendingBboxCalculation = false;
|
||||
|
||||
this._manager.stateApi.onShiftChanged((isPressed) => {
|
||||
// Use shift enable/disable rotation snaps
|
||||
this.konva.transformer.rotationSnaps(isPressed ? [0, 45, 90, 135, 180, 225, 270, 315] : []);
|
||||
});
|
||||
}
|
||||
|
||||
destroy(): void {
|
||||
|
Loading…
x
Reference in New Issue
Block a user