Allow for autosize to be specified as hidden input

This commit is contained in:
Austin Mroz
2024-09-22 04:03:19 -05:00
parent 261fac8a01
commit 15f9dd5b34
+21 -8
View File
@@ -1,6 +1,26 @@
import { app } from '../../../scripts/app.js'
function addResizeHook(node, padding) {
let origOnCreated = node.onNodeCreated
node.onNodeCreated = function() {
let r = origOnCreated?.apply(this, arguments)
let size = this.computeSize();
size[0] += padding || 0;
this.setSize(size);
return r
}
}
app.registerExtension({
name: "AnimateDiffEvolved.autosize",
async beforeRegisterNodeDef(nodeType, nodeData, app) {
if (nodeData?.name?.startsWith("ADE_")) {
if (nodeData?.input?.hidden?.autosize) {
addResizeHook(nodeType.prototype, nodeData.input.hidden.autosize[1]?.padding)
}
}
},
async getCustomWidgets() {
return {
ADEAUTOSIZE(node, inputName, inputData) {
@@ -17,14 +37,7 @@ app.registerExtension({
node.widgets = []
}
node.widgets.push(w)
let origOnCreated = node.onNodeCreated
node.onNodeCreated = function() {
let r = origOnCreated?.apply(this, arguments)
let size = this.computeSize();
size[0] += inputData[1].padding || 0;
this.setSize(size);
return r
}
addResizeHook(node, inputData[1].padding);
return w;
}
}