fix(ui): no objects rendered until vis toggled

This commit is contained in:
psychedelicious 2024-08-06 13:37:41 +10:00
parent 9378656d78
commit 340af1fe50
2 changed files with 5 additions and 5 deletions

View File

@ -117,6 +117,6 @@ export class CanvasInpaintMask {
updateVisibility = (arg?: { isEnabled: boolean }) => { updateVisibility = (arg?: { isEnabled: boolean }) => {
this.log.trace('Updating visibility'); this.log.trace('Updating visibility');
const isEnabled = get(arg, 'isEnabled', this.state.isEnabled); const isEnabled = get(arg, 'isEnabled', this.state.isEnabled);
this.konva.layer.visible(isEnabled && this.renderer.hasObjects()); this.konva.layer.visible(isEnabled);
}; };
} }

View File

@ -70,6 +70,9 @@ export class CanvasLayer {
this.log.debug('Updating'); this.log.debug('Updating');
const { position, objects, opacity, isEnabled } = state; const { position, objects, opacity, isEnabled } = state;
if (this.isFirstRender || isEnabled !== this.state.isEnabled) {
this.updateVisibility({ isEnabled });
}
if (this.isFirstRender || objects !== this.state.objects) { if (this.isFirstRender || objects !== this.state.objects) {
await this.updateObjects({ objects }); await this.updateObjects({ objects });
} }
@ -79,9 +82,6 @@ export class CanvasLayer {
if (this.isFirstRender || opacity !== this.state.opacity) { if (this.isFirstRender || opacity !== this.state.opacity) {
this.updateOpacity({ opacity }); this.updateOpacity({ opacity });
} }
if (this.isFirstRender || isEnabled !== this.state.isEnabled) {
this.updateVisibility({ isEnabled });
}
// this.transformer.syncInteractionState(); // this.transformer.syncInteractionState();
if (this.isFirstRender) { if (this.isFirstRender) {
@ -95,7 +95,7 @@ export class CanvasLayer {
updateVisibility = (arg?: { isEnabled: boolean }) => { updateVisibility = (arg?: { isEnabled: boolean }) => {
this.log.trace('Updating visibility'); this.log.trace('Updating visibility');
const isEnabled = get(arg, 'isEnabled', this.state.isEnabled); const isEnabled = get(arg, 'isEnabled', this.state.isEnabled);
this.konva.layer.visible(isEnabled && this.renderer.hasObjects()); this.konva.layer.visible(isEnabled);
}; };
updateObjects = async (arg?: { objects: CanvasLayerState['objects'] }) => { updateObjects = async (arg?: { objects: CanvasLayerState['objects'] }) => {