From f481a67c4617ef47a42f637c4325a390c204c53a Mon Sep 17 00:00:00 2001 From: Austin Mroz Date: Tue, 23 Dec 2025 21:19:17 -0800 Subject: [PATCH 1/2] Workaround for reload causing node spread --- src/lib/litegraph/src/DragAndScale.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/lib/litegraph/src/DragAndScale.ts b/src/lib/litegraph/src/DragAndScale.ts index c71fca2d25f..f362bd9a3ba 100644 --- a/src/lib/litegraph/src/DragAndScale.ts +++ b/src/lib/litegraph/src/DragAndScale.ts @@ -192,8 +192,12 @@ export class DragAndScale { bounds: ReadOnlyRect, { zoom = 0.75 }: { zoom?: number } = {} ): void { - const cw = this.element.width / window.devicePixelRatio - const ch = this.element.height / window.devicePixelRatio + const [width, height] = + this.element.width === 300 && this.element.height === 150 + ? [1920, 1080] + : [this.element.width, this.element.height] + const cw = width / window.devicePixelRatio + const ch = height / window.devicePixelRatio let targetScale = this.scale if (zoom > 0) { From 11be3e1523a9feec43fbb83f489ac88f3e58169b Mon Sep 17 00:00:00 2001 From: Austin Mroz Date: Tue, 23 Dec 2025 22:48:20 -0800 Subject: [PATCH 2/2] Nit comment --- src/lib/litegraph/src/DragAndScale.ts | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/lib/litegraph/src/DragAndScale.ts b/src/lib/litegraph/src/DragAndScale.ts index f362bd9a3ba..d2e35252d24 100644 --- a/src/lib/litegraph/src/DragAndScale.ts +++ b/src/lib/litegraph/src/DragAndScale.ts @@ -192,6 +192,8 @@ export class DragAndScale { bounds: ReadOnlyRect, { zoom = 0.75 }: { zoom?: number } = {} ): void { + //If element hasn't initialized (browser tab is in background) + //it has a size of 300x150 and a more reasonable default is used instead. const [width, height] = this.element.width === 300 && this.element.height === 150 ? [1920, 1080]