From 38a513f09f571165686b6e23864ba6bf2660c464 Mon Sep 17 00:00:00 2001 From: Austin Mroz Date: Fri, 25 Oct 2024 02:46:01 -0500 Subject: [PATCH] Shrink width of long title nodes by default Because of a change in initialization order. ComfyUI now considers a node's title before scaling by 1.5 to determine a nodes initial width. This causes nodes with long titles to have correspondingly large dead space. As a rough fix, ADE nodes are changed to have initial size equal to the greater of the default node width or the minimum title length. --- web/js/autosize.js | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/web/js/autosize.js b/web/js/autosize.js index 80882b3..543b85e 100644 --- a/web/js/autosize.js +++ b/web/js/autosize.js @@ -1,23 +1,31 @@ import { app } from '../../../scripts/app.js' -function addResizeHook(node, padding) { +function addResizeHook(node, padding, useOldMin=false) { let origOnCreated = node.onNodeCreated node.onNodeCreated = function() { let r = origOnCreated?.apply(this, arguments) let size = this.computeSize(); size[0] += padding || 0; + if (useOldMin) { + //equal to LiteGraph.NODE_WIDTH*1.5*1.5 + size[0] = Math.max(size[0], 315) + } this.setSize(size); return r } } - app.registerExtension({ name: "AnimateDiffEvolved.autosize", async beforeRegisterNodeDef(nodeType, nodeData, app) { - if (nodeData?.name?.startsWith("ADE_")) { + //since python_module is based off folder path, + //it could be changed by users and should only be used as fallback + if (nodeData?.name?.startsWith("ADE_") + || nodeData.python_module == 'custom_nodes.ComfyUI-AnimateDiff-Evolved') { if (nodeData?.input?.hidden?.autosize) { addResizeHook(nodeType.prototype, nodeData.input.hidden.autosize[1]?.padding) + } else if (!nodeData?.input?.optional?.autosize) { + addResizeHook(nodeType.prototype, 0, true) } } },