Match CSGlide node height management
This commit is contained in:
@@ -37,14 +37,17 @@ function configure(node) {
|
||||
panel.style.cssText = "box-sizing:border-box;width:calc(100% + 14px);margin-left:-7px;min-width:420px;padding:9px;color:#d9e3dc;background:#292929;border:1px solid #454545;border-radius:4px;font:12px Arial;pointer-events:auto";
|
||||
const host = el("div"); host.style.cssText = "box-sizing:border-box;pointer-events:auto;background:#292929;width:100%"; host.append(panel);
|
||||
["pointerdown", "mousedown", "mouseup", "dblclick"].forEach((name) => host.addEventListener(name, (event) => event.stopPropagation()));
|
||||
let panelHeight = 54;
|
||||
const display = node.addDOMWidget("clip_tabs", "dumas_h3_clip_tabs", host, {
|
||||
serialize: false,
|
||||
// Current ComfyUI uses DOMWidgetOptions.getMinHeight() for LiteGraph
|
||||
// layout; widget.computeSize() is not consulted for the node frame.
|
||||
getMinHeight: () => panelHeight,
|
||||
getMaxHeight: () => panelHeight,
|
||||
});
|
||||
const display = node.addDOMWidget("clip_tabs", "dumas_h3_clip_tabs", host, { serialize: false });
|
||||
if (!node.__dumasSequenceResizeWrapped) {
|
||||
const previousResize = node.onResize;
|
||||
node.onResize = function (size) {
|
||||
if (this.__dumasSequenceMinHeight > 0 && size[1] < this.__dumasSequenceMinHeight) {
|
||||
size[1] = this.__dumasSequenceMinHeight;
|
||||
}
|
||||
return previousResize?.apply(this, arguments);
|
||||
};
|
||||
node.__dumasSequenceResizeWrapped = true;
|
||||
}
|
||||
display.options ||= {}; display.options.serialize = false;
|
||||
let active = 0;
|
||||
let state = readState(stateWidget, Number(countWidget.value) || 2, Number(secondsWidget.value) || 4);
|
||||
@@ -268,12 +271,20 @@ function configure(node) {
|
||||
// the old slot-count estimate left a large blank tail in the node.
|
||||
// Measure the actual DOM panel instead of guessing from slot count.
|
||||
const measuredHeight = Math.ceil(panel.getBoundingClientRect().height || panel.scrollHeight || 0);
|
||||
panelHeight = measuredHeight;
|
||||
display.computeSize = (width) => [Math.max(420, Number(width) || 420), measuredHeight + 2];
|
||||
// CSGlide keeps the DOM panel floating but stores a node-level floor
|
||||
// from measured content. Temporarily hide this widget from the
|
||||
// ordinary LiteGraph calculation to get the non-panel chrome, then
|
||||
// add the real panel height and clamp future manual resizes.
|
||||
const realComputeSize = display.computeSize;
|
||||
display.computeSize = () => [420, 0];
|
||||
const chromeHeight = Number(node.computeSize?.()[1]) || 0;
|
||||
display.computeSize = realComputeSize;
|
||||
const width = Math.max(420, Number(node.size?.[0]) || 420);
|
||||
const desiredHeight = Number(node.computeSize?.()[1]) || 0;
|
||||
const desiredHeight = chromeHeight + measuredHeight + 2;
|
||||
node.__dumasSequenceMinHeight = desiredHeight;
|
||||
if (typeof node.setSize === "function"
|
||||
&& (Number(node.size?.[0]) !== width || Number(node.size?.[1]) !== desiredHeight)) {
|
||||
&& (Number(node.size?.[0]) !== width || Number(node.size?.[1]) < desiredHeight)) {
|
||||
node.setSize([width, desiredHeight]);
|
||||
}
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user