From 05b09189152e5e8d9af7ed772e4d8f165d50c1d9 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Thu, 3 Apr 2025 23:08:28 +1100 Subject: [PATCH] Support dragging reroutes from floating links (#878) Allows dragging reroutes from floating links. --- src/LGraph.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/src/LGraph.ts b/src/LGraph.ts index 082e7c10f..4568bd20a 100644 --- a/src/LGraph.ts +++ b/src/LGraph.ts @@ -1250,7 +1250,10 @@ export class LGraph implements LinkNetwork, Serialisable { const linkIds = before instanceof Reroute ? before.linkIds : [before.id] - const reroute = new Reroute(rerouteId, this, pos, before.parentId, linkIds) + const floatingLinkIds = before instanceof Reroute + ? before.floatingLinkIds + : [before.id] + const reroute = new Reroute(rerouteId, this, pos, before.parentId, linkIds, floatingLinkIds) this.reroutes.set(rerouteId, reroute) for (const linkId of linkIds) { const link = this._links.get(linkId) @@ -1263,6 +1266,17 @@ export class LGraph implements LinkNetwork, Serialisable { } } + for (const linkId of floatingLinkIds) { + const link = this.floatingLinks.get(linkId) + if (!link) continue + if (link.parentId === before.parentId) link.parentId = rerouteId + + const reroutes = LLink.getReroutes(this, link) + for (const x of reroutes.filter(x => x.parentId === before.parentId)) { + x.parentId = rerouteId + } + } + return reroute }