diff --git a/src/lib/litegraph/src/LGraphCanvas.ts b/src/lib/litegraph/src/LGraphCanvas.ts index 9e7ef226fd..fade868c2a 100644 --- a/src/lib/litegraph/src/LGraphCanvas.ts +++ b/src/lib/litegraph/src/LGraphCanvas.ts @@ -6314,7 +6314,14 @@ export class LGraphCanvas } // that.graph.beforeChange(); - const newNode = LiteGraph.createNode(nodeNewType) + const xSizeFix = opts.posSizeFix[0] * LiteGraph.NODE_WIDTH + const ySizeFix = opts.posSizeFix[1] * LiteGraph.NODE_SLOT_HEIGHT + const nodeX = opts.position[0] + opts.posAdd[0] + xSizeFix + const nodeY = opts.position[1] + opts.posAdd[1] + ySizeFix + const pos = [nodeX, nodeY] + const newNode = LiteGraph.createNode(nodeNewType, nodeNewOpts.title, { + pos + }) if (newNode) { // if is object pass options if (nodeNewOpts) { @@ -6341,9 +6348,6 @@ export class LGraphCanvas ) } } - if (nodeNewOpts.title) { - newNode.title = nodeNewOpts.title - } if (nodeNewOpts.json) { newNode.configure(nodeNewOpts.json) } @@ -6353,14 +6357,6 @@ export class LGraphCanvas if (!this.graph) throw new NullGraphError() this.graph.add(newNode) - newNode.pos = [ - opts.position[0] + - opts.posAdd[0] + - (opts.posSizeFix[0] ? opts.posSizeFix[0] * newNode.size[0] : 0), - opts.position[1] + - opts.posAdd[1] + - (opts.posSizeFix[1] ? opts.posSizeFix[1] * newNode.size[1] : 0) - ] // Interim API - allow the link connection to be canceled. // TODO: https://github.com/Comfy-Org/litegraph.js/issues/946