From a76c50252b56265b63cca4b14111338143063da3 Mon Sep 17 00:00:00 2001 From: filtered <176114999+webfiltered@users.noreply.github.com> Date: Sun, 20 Apr 2025 18:52:01 +1000 Subject: [PATCH] Fix part of snapped link follows pointer (#945) Removes the green circle that always follows the pointer, even when a link is snapped elsewhere. --- src/LGraphCanvas.ts | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/src/LGraphCanvas.ts b/src/LGraphCanvas.ts index 7576c15910..1058498dcf 100644 --- a/src/LGraphCanvas.ts +++ b/src/LGraphCanvas.ts @@ -3851,11 +3851,9 @@ export class LGraphCanvas implements ConnectionColorContext { ctx.beginPath() if (connType === LiteGraph.EVENT || connShape === RenderShape.BOX) { ctx.rect(pos[0] - 6 + 0.5, pos[1] - 5 + 0.5, 14, 10) - ctx.fill() - ctx.beginPath() ctx.rect( - this.graph_mouse[0] - 6 + 0.5, - this.graph_mouse[1] - 5 + 0.5, + highlightPos[0] - 6 + 0.5, + highlightPos[1] - 5 + 0.5, 14, 10, ) @@ -3866,9 +3864,7 @@ export class LGraphCanvas implements ConnectionColorContext { ctx.closePath() } else { ctx.arc(pos[0], pos[1], 4, 0, Math.PI * 2) - ctx.fill() - ctx.beginPath() - ctx.arc(this.graph_mouse[0], this.graph_mouse[1], 4, 0, Math.PI * 2) + ctx.arc(highlightPos[0], highlightPos[1], 4, 0, Math.PI * 2) } ctx.fill() } @@ -3962,10 +3958,10 @@ export class LGraphCanvas implements ConnectionColorContext { } ctx.fill() - if (!LiteGraph.snap_highlights_node) return - const { linkConnector } = this const { overReroute, overWidget } = linkConnector + if (!LiteGraph.snap_highlights_node || !linkConnector.isConnecting) return + // Reroute highlight if (overReroute) { const { globalAlpha } = ctx @@ -3976,7 +3972,7 @@ export class LGraphCanvas implements ConnectionColorContext { // Ensure we're mousing over a node and connecting a link const node = this.node_over - if (!(node && linkConnector.isConnecting)) return + if (!node) return const { strokeStyle, lineWidth } = ctx