mirror of
https://github.com/invoke-ai/InvokeAI.git
synced 2026-02-02 20:55:09 -05:00
fix(ui): do not floor stage coords, add util to sync stage attrs
This commit is contained in:
@@ -129,13 +129,7 @@ export class CanvasStageModule extends CanvasModuleBase {
|
||||
|
||||
this.konva.stage.width(containerWidth);
|
||||
this.konva.stage.height(containerHeight);
|
||||
this.$stageAttrs.set({
|
||||
x: this.konva.stage.x(),
|
||||
y: this.konva.stage.y(),
|
||||
width: this.konva.stage.width(),
|
||||
height: this.konva.stage.height(),
|
||||
scale: this.konva.stage.scaleX(),
|
||||
});
|
||||
this.syncStageAttrs();
|
||||
|
||||
if (shouldFitLayersAfterFittingStage) {
|
||||
this.fitLayersToStage();
|
||||
@@ -215,12 +209,7 @@ export class CanvasStageModule extends CanvasModuleBase {
|
||||
scaleY: scale,
|
||||
});
|
||||
|
||||
this.$stageAttrs.set({
|
||||
...this.$stageAttrs.get(),
|
||||
x,
|
||||
y,
|
||||
scale,
|
||||
});
|
||||
this.syncStageAttrs({ x, y, scale });
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -276,13 +265,7 @@ export class CanvasStageModule extends CanvasModuleBase {
|
||||
scaleY: newScale,
|
||||
});
|
||||
|
||||
this.$stageAttrs.set({
|
||||
x: Math.floor(this.konva.stage.x()),
|
||||
y: Math.floor(this.konva.stage.y()),
|
||||
width: this.konva.stage.width(),
|
||||
height: this.konva.stage.height(),
|
||||
scale: this.konva.stage.scaleX(),
|
||||
});
|
||||
this.syncStageAttrs();
|
||||
};
|
||||
|
||||
onStageMouseWheel = (e: KonvaEventObject<WheelEvent>) => {
|
||||
@@ -308,14 +291,7 @@ export class CanvasStageModule extends CanvasModuleBase {
|
||||
return;
|
||||
}
|
||||
|
||||
this.$stageAttrs.set({
|
||||
// Stage position should always be an integer, else we get fractional pixels which are blurry
|
||||
x: Math.floor(this.konva.stage.x()),
|
||||
y: Math.floor(this.konva.stage.y()),
|
||||
width: this.konva.stage.width(),
|
||||
height: this.konva.stage.height(),
|
||||
scale: this.konva.stage.scaleX(),
|
||||
});
|
||||
this.syncStageAttrs();
|
||||
};
|
||||
|
||||
onStageDragEnd = (e: KonvaEventObject<DragEvent>) => {
|
||||
@@ -323,14 +299,7 @@ export class CanvasStageModule extends CanvasModuleBase {
|
||||
return;
|
||||
}
|
||||
|
||||
this.$stageAttrs.set({
|
||||
// Stage position should always be an integer, else we get fractional pixels which are blurry
|
||||
x: Math.floor(this.konva.stage.x()),
|
||||
y: Math.floor(this.konva.stage.y()),
|
||||
width: this.konva.stage.width(),
|
||||
height: this.konva.stage.height(),
|
||||
scale: this.konva.stage.scaleX(),
|
||||
});
|
||||
this.syncStageAttrs();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -370,6 +339,17 @@ export class CanvasStageModule extends CanvasModuleBase {
|
||||
this.container.style.cursor = cursor;
|
||||
};
|
||||
|
||||
syncStageAttrs = (overrides?: Partial<StageAttrs>) => {
|
||||
this.$stageAttrs.set({
|
||||
x: this.konva.stage.x(),
|
||||
y: this.konva.stage.y(),
|
||||
width: this.konva.stage.width(),
|
||||
height: this.konva.stage.height(),
|
||||
scale: this.konva.stage.scaleX(),
|
||||
...overrides,
|
||||
});
|
||||
};
|
||||
|
||||
setIsDraggable = (isDraggable: boolean) => {
|
||||
this.konva.stage.draggable(isDraggable);
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user