Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/LGraphCanvas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3951,7 +3951,7 @@ export class LGraphCanvas implements ConnectionColorContext {
/** Get the target snap / highlight point in graph space */
#getHighlightPosition(): ReadOnlyPoint {
return LiteGraph.snaps_for_comfy
? this._highlight_pos ?? this.graph_mouse
? this.linkConnector.state.snapLinksPos ?? this._highlight_pos ?? this.graph_mouse
: this.graph_mouse
}

Expand All @@ -3964,7 +3964,8 @@ export class LGraphCanvas implements ConnectionColorContext {
ctx: CanvasRenderingContext2D,
highlightPos: ReadOnlyPoint,
): void {
if (!this._highlight_pos) return
const linkConnectorSnap = !!this.linkConnector.state.snapLinksPos
if (!this._highlight_pos && !linkConnectorSnap) return

ctx.fillStyle = "#ffcc00"
ctx.beginPath()
Expand All @@ -3982,7 +3983,7 @@ export class LGraphCanvas implements ConnectionColorContext {

const { linkConnector } = this
const { overReroute, overWidget } = linkConnector
if (!LiteGraph.snap_highlights_node || !linkConnector.isConnecting) return
if (!LiteGraph.snap_highlights_node || !linkConnector.isConnecting || linkConnectorSnap) return

// Reroute highlight
if (overReroute) {
Expand Down
4 changes: 4 additions & 0 deletions src/canvas/LinkConnector.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export interface LinkConnectorState {
multi: boolean
/** When `true`, existing links are being repositioned. Otherwise, new links are being created. */
draggingExistingLinks: boolean
/** When set, connecting links will all snap to this position. */
snapLinksPos?: [number, number]
}

/** Discriminated union to simplify type narrowing. */
Expand Down Expand Up @@ -61,6 +63,7 @@ export class LinkConnector {
connectingTo: undefined,
multi: false,
draggingExistingLinks: false,
snapLinksPos: undefined,
}

readonly events = new LinkConnectorEventTarget()
Expand Down Expand Up @@ -639,6 +642,7 @@ export class LinkConnector {
hiddenReroutes.clear()
state.multi = false
state.draggingExistingLinks = false
state.snapLinksPos = undefined
}
}

Expand Down