diff --git a/animatediff/nodes_sample.py b/animatediff/nodes_sample.py index 1c5a143..a4041f2 100644 --- a/animatediff/nodes_sample.py +++ b/animatediff/nodes_sample.py @@ -298,6 +298,7 @@ class CustomCFGKeyframeSimpleNode: "optional": { "prev_custom_cfg": ("CUSTOM_CFG",), "cfg_extras": ("CFG_EXTRAS",), + "autosize": ("ADEAUTOSIZE", {"padding": 10}), } } diff --git a/web/js/autosize.js b/web/js/autosize.js index 4961ddc..ccf1cfd 100644 --- a/web/js/autosize.js +++ b/web/js/autosize.js @@ -1,14 +1,31 @@ import { app } from '../../../scripts/app.js' app.registerExtension({ name: "AnimateDiffEvolved.autosize", - async beforeRegisterNodeDef(nodeType, nodeData, app) { - if(nodeData?.name?.startsWith("ADE_") || - nodeData?.name?.startsWith("ACN_")) { - let origOnCreated = nodeType.prototype.onNodeCreated - nodeType.prototype.onNodeCreated = function() { - const r = origOnCreated ? origOnCreated.apply(this) : undefined; - this.setSize(this.computeSize(0)); - return r + async nodeCreated(node) { + if(node.adeAutosize) { + let size = node.computeSize(0); + size[0] += node.adeAutosize?.padding || 0; + node.setSize(size); + } + }, + async getCustomWidgets() { + return { + ADEAUTOSIZE(node, inputName, inputData) { + let w = { + name : inputName, + type : "ADE.AUTOSIZE", + value : "", + options : {"serialize": false}, + computeSize : function(width) { + return [0, -4]; + } + } + node.adeAutosize = inputData[1]; + if (!node.widgets) { + node.widgets = [] + } + node.widgets.push(w) + return w; } } }