Merge pull request #490 from AustinMroz/main
Shrink width of long title nodes by default
This commit is contained in:
+11
-3
@@ -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)
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user