From 99d0de239cda38bc8321097feb9ba1af40fe4a9b Mon Sep 17 00:00:00 2001 From: Chenlei Hu Date: Wed, 4 Sep 2024 15:45:22 -0400 Subject: [PATCH] Fix collapse and resize (#121) --- public/litegraph.d.ts | 1 + src/litegraph.js | 13 +++++++++++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/public/litegraph.d.ts b/public/litegraph.d.ts index 037491b6e..5f0276e70 100644 --- a/public/litegraph.d.ts +++ b/public/litegraph.d.ts @@ -965,6 +965,7 @@ export declare class LGraphNode { /** Allows to get onMouseMove and onMouseUp events even if the mouse is out of focus */ captureInput(v: any): void; + get collapsed(): boolean; get collapsible(): boolean; /** Collapse the node to make it smaller on the canvas */ collapse(force: boolean): void; diff --git a/src/litegraph.js b/src/litegraph.js index dbde929f5..6a2cbbe8f 100755 --- a/src/litegraph.js +++ b/src/litegraph.js @@ -2469,6 +2469,11 @@ const globalExport = {}; } } + // Sync the state of this.resizable. + if (this.pinned) { + this.pin(true); + } + if (this.onConfigure) { this.onConfigure(info); } @@ -4755,8 +4760,12 @@ const globalExport = {}; } } + get collapsed() { + return !!this.flags.collapsed; + } + get collapsible() { - return !this.pinned && this.constructor.collapsable; + return !this.pinned && (this.constructor.collapsable !== false); } /** @@ -4765,7 +4774,7 @@ const globalExport = {}; **/ collapse(force) { this.graph._version++; - if (this.collapsible && !force) { + if (!this.collapsible && !force) { return; } if (!this.flags.collapsed) {