mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2026-02-16 08:22:36 +08:00
Apply value on connect
This commit is contained in:
parent
4a31f461c8
commit
49b97dc5d8
@ -308,7 +308,7 @@ app.registerExtension({
|
|||||||
this.isVirtualNode = true;
|
this.isVirtualNode = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
applyToGraph() {
|
applyToGraph(extraLinks = []) {
|
||||||
if (!this.outputs[0].links?.length) return;
|
if (!this.outputs[0].links?.length) return;
|
||||||
|
|
||||||
function get_links(node) {
|
function get_links(node) {
|
||||||
@ -325,10 +325,9 @@ app.registerExtension({
|
|||||||
return links;
|
return links;
|
||||||
}
|
}
|
||||||
|
|
||||||
let links = get_links(this);
|
let links = [...get_links(this).map((l) => app.graph.links[l]), ...extraLinks];
|
||||||
// For each output link copy our value over the original widget value
|
// For each output link copy our value over the original widget value
|
||||||
for (const l of links) {
|
for (const linkInfo of links) {
|
||||||
const linkInfo = app.graph.links[l];
|
|
||||||
const node = this.graph.getNodeById(linkInfo.target_id);
|
const node = this.graph.getNodeById(linkInfo.target_id);
|
||||||
const input = node.inputs[linkInfo.target_slot];
|
const input = node.inputs[linkInfo.target_slot];
|
||||||
const widgetName = input.widget.name;
|
const widgetName = input.widget.name;
|
||||||
@ -405,7 +404,12 @@ app.registerExtension({
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (this.outputs[slot].links?.length) {
|
if (this.outputs[slot].links?.length) {
|
||||||
return this.#isValidConnection(input);
|
const valid = this.#isValidConnection(input);
|
||||||
|
if (valid) {
|
||||||
|
// On connect of additional outputs, copy our value to their widget
|
||||||
|
this.applyToGraph([{ target_id: target_node.id, target_slot }]);
|
||||||
|
}
|
||||||
|
return valid;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user