Skip to content

Commit f7ea036

Browse files
committed
feat(litegraph): use layoutStore slot positions for node slot queries\n\n- Route getInputPos/getInputSlotPos/getOutputPos through getSlotPosition(), which prefers layoutStore DOM-tracked positions and falls back to geometry.\n- Ensures reroute-origin drags snap to visually tracked node slots when hovering compatible nodes in Vue nodes mode.\n- No change for non-Vue nodes mode or when no tracked slot layout is present.
1 parent b00e429 commit f7ea036

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/lib/litegraph/src/LGraphNode.ts

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
import { LGraphNodeProperties } from '@/lib/litegraph/src/LGraphNodeProperties'
22
import {
33
type SlotPositionContext,
4-
calculateInputSlotPos,
54
calculateInputSlotPosFromSlot,
6-
calculateOutputSlotPos
5+
getSlotPosition
76
} from '@/renderer/core/canvas/litegraph/slotCalculations'
87
import { useLayoutMutations } from '@/renderer/core/layout/operations/layoutMutations'
98
import { LayoutSource } from '@/renderer/core/layout/types'
@@ -3267,7 +3266,7 @@ export class LGraphNode
32673266
* @returns Position of the input slot
32683267
*/
32693268
getInputPos(slot: number): Point {
3270-
return calculateInputSlotPos(this.#getSlotPositionContext(), slot)
3269+
return getSlotPosition(this, slot, true)
32713270
}
32723271

32733272
/**
@@ -3276,18 +3275,21 @@ export class LGraphNode
32763275
* @returns Position of the centre of the input slot in graph co-ordinates.
32773276
*/
32783277
getInputSlotPos(input: INodeInputSlot): Point {
3278+
const idx = this.inputs.indexOf(input)
3279+
if (idx !== -1) return getSlotPosition(this, idx, true)
3280+
// Fallback when slot instance is not found in inputs
32793281
return calculateInputSlotPosFromSlot(this.#getSlotPositionContext(), input)
32803282
}
32813283

32823284
/**
32833285
* Gets the position of an output slot, in graph co-ordinates.
32843286
*
32853287
* This method is preferred over the legacy {@link getConnectionPos} method.
3286-
* @param slot Output slot index
3288+
* @param outputSlotIndex Output slot index
32873289
* @returns Position of the output slot
32883290
*/
3289-
getOutputPos(slot: number): Point {
3290-
return calculateOutputSlotPos(this.#getSlotPositionContext(), slot)
3291+
getOutputPos(outputSlotIndex: number): Point {
3292+
return getSlotPosition(this, outputSlotIndex, false)
32913293
}
32923294

32933295
/** @inheritdoc */

0 commit comments

Comments
 (0)