Allow for autosize to be specified as hidden input
This commit is contained in:
+21
-8
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user