mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-05-01 19:51:54 +00:00
added beforeChange and afterChange to graph.remove( node )
This commit is contained in:
@@ -1367,6 +1367,8 @@
|
||||
return;
|
||||
} //cannot be removed
|
||||
|
||||
this.beforeChange(); //sure?
|
||||
|
||||
//disconnect inputs
|
||||
if (node.inputs) {
|
||||
for (var i = 0; i < node.inputs.length; i++) {
|
||||
@@ -1425,6 +1427,7 @@
|
||||
this.sendActionToCanvas("checkPanels");
|
||||
|
||||
this.setDirtyCanvas(true, true);
|
||||
this.afterChange(); //sure?
|
||||
this.change();
|
||||
|
||||
this.updateExecutionOrder();
|
||||
@@ -3711,37 +3714,43 @@
|
||||
}
|
||||
|
||||
var changed = false;
|
||||
var input = target_node.inputs[target_slot];
|
||||
var output = this.outputs[slot];
|
||||
var link_info = null;
|
||||
|
||||
if (LiteGraph.isValidConnection(output.type, input.type)) {
|
||||
if (target_node.onBeforeConnectInput) {
|
||||
// This way node can choose another slot (if selected is occupied)
|
||||
target_slot = target_node.onBeforeConnectInput(target_slot);
|
||||
}
|
||||
|
||||
//if there is something already plugged there, disconnect
|
||||
if (target_node.inputs[target_slot].link != null) {
|
||||
this.graph.beforeChange();
|
||||
target_node.disconnectInput(target_slot);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
//why here??
|
||||
//this.setDirtyCanvas(false,true);
|
||||
//this.graph.connectionChange( this );
|
||||
|
||||
var output = this.outputs[slot];
|
||||
|
||||
//allows nodes to block connection
|
||||
if (target_node.onConnectInput) {
|
||||
if ( target_node.onConnectInput(target_slot, output.type, output, this, slot) === false ) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (this.onConnectOutput) {
|
||||
if ( this.onConnectOutput(slot, input.type, input, target_node, target_slot) === false ) {
|
||||
|
||||
var input = target_node.inputs[target_slot];
|
||||
var link_info = null;
|
||||
|
||||
//this slots cannot be connected (different types)
|
||||
if (!LiteGraph.isValidConnection(output.type, input.type))
|
||||
{
|
||||
this.setDirtyCanvas(false, true);
|
||||
if(changed)
|
||||
this.graph.connectionChange(this, link_info);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if(!changed)
|
||||
this.graph.beforeChange();
|
||||
|
||||
//create link class
|
||||
link_info = new LLink(
|
||||
++this.graph.last_link_id,
|
||||
input.type,
|
||||
@@ -3798,7 +3807,6 @@
|
||||
target_slot
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
this.setDirtyCanvas(false, true);
|
||||
this.graph.afterChange();
|
||||
|
||||
1180
build/litegraph.min.js
vendored
1180
build/litegraph.min.js
vendored
File diff suppressed because it is too large
Load Diff
@@ -1365,6 +1365,8 @@
|
||||
return;
|
||||
} //cannot be removed
|
||||
|
||||
this.beforeChange(); //sure?
|
||||
|
||||
//disconnect inputs
|
||||
if (node.inputs) {
|
||||
for (var i = 0; i < node.inputs.length; i++) {
|
||||
@@ -1423,6 +1425,7 @@
|
||||
this.sendActionToCanvas("checkPanels");
|
||||
|
||||
this.setDirtyCanvas(true, true);
|
||||
this.afterChange(); //sure?
|
||||
this.change();
|
||||
|
||||
this.updateExecutionOrder();
|
||||
@@ -3709,37 +3712,43 @@
|
||||
}
|
||||
|
||||
var changed = false;
|
||||
var input = target_node.inputs[target_slot];
|
||||
var output = this.outputs[slot];
|
||||
var link_info = null;
|
||||
|
||||
if (LiteGraph.isValidConnection(output.type, input.type)) {
|
||||
if (target_node.onBeforeConnectInput) {
|
||||
// This way node can choose another slot (if selected is occupied)
|
||||
target_slot = target_node.onBeforeConnectInput(target_slot);
|
||||
}
|
||||
|
||||
//if there is something already plugged there, disconnect
|
||||
if (target_node.inputs[target_slot].link != null) {
|
||||
this.graph.beforeChange();
|
||||
target_node.disconnectInput(target_slot);
|
||||
changed = true;
|
||||
}
|
||||
|
||||
//why here??
|
||||
//this.setDirtyCanvas(false,true);
|
||||
//this.graph.connectionChange( this );
|
||||
|
||||
var output = this.outputs[slot];
|
||||
|
||||
//allows nodes to block connection
|
||||
if (target_node.onConnectInput) {
|
||||
if ( target_node.onConnectInput(target_slot, output.type, output, this, slot) === false ) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
if (this.onConnectOutput) {
|
||||
if ( this.onConnectOutput(slot, input.type, input, target_node, target_slot) === false ) {
|
||||
|
||||
var input = target_node.inputs[target_slot];
|
||||
var link_info = null;
|
||||
|
||||
//this slots cannot be connected (different types)
|
||||
if (!LiteGraph.isValidConnection(output.type, input.type))
|
||||
{
|
||||
this.setDirtyCanvas(false, true);
|
||||
if(changed)
|
||||
this.graph.connectionChange(this, link_info);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
if(!changed)
|
||||
this.graph.beforeChange();
|
||||
|
||||
//create link class
|
||||
link_info = new LLink(
|
||||
++this.graph.last_link_id,
|
||||
input.type,
|
||||
@@ -3796,7 +3805,6 @@
|
||||
target_slot
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
this.setDirtyCanvas(false, true);
|
||||
this.graph.afterChange();
|
||||
|
||||
Reference in New Issue
Block a user