Added autosize js code

This commit is contained in:
Jedrzej Kosinski
2024-07-15 20:45:39 -05:00
parent 36fdc79e2c
commit 0ec21e4d93
2 changed files with 34 additions and 1 deletions
+32
View File
@@ -0,0 +1,32 @@
import { app } from '../../../scripts/app.js'
app.registerExtension({
name: "AdvancedControlNet.autosize",
async nodeCreated(node) {
if(node.acnAutosize) {
let size = node.computeSize(0);
size[0] += node.acnAutosize?.padding || 0;
node.setSize(size);
}
},
async getCustomWidgets() {
return {
ACNAUTOSIZE(node, inputName, inputData) {
let w = {
name : inputName,
type : "ACN.AUTOSIZE",
value : "",
options : {"serialize": false},
computeSize : function(width) {
return [0, -4];
}
}
node.acnAutosize = inputData[1];
if (!node.widgets) {
node.widgets = []
}
node.widgets.push(w)
return w;
}
}
}
});