Skip to content

Commit b50b34a

Browse files
authored
Expose LGraphNode.getSlotPosition (#7042)
Before node v2, you could use getInputPos, getOutputPos. In node v2, that is not possible. ## Summary Want to get the position of the output / inputs on the graph like before node v2. ## Changes - **What**: <!-- Core functionality added/modified --> Added LGraphNode.getSlotPosition ## Review Focus ## Screenshots (if applicable) ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7042-Expose-LGraphNode-getSlotPosition-2ba6d73d36508195a0fed2d1fe2b64f6) by [Unito](https://www.unito.io)
1 parent 7a6cc39 commit b50b34a

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

src/lib/litegraph/src/LGraphNode.ts

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import { LGraphNodeProperties } from '@/lib/litegraph/src/LGraphNodeProperties'
22
import {
33
calculateInputSlotPos,
44
calculateInputSlotPosFromSlot,
5-
calculateOutputSlotPos
5+
calculateOutputSlotPos,
6+
getSlotPosition
67
} from '@/renderer/core/canvas/litegraph/slotCalculations'
78
import type { SlotPositionContext } from '@/renderer/core/canvas/litegraph/slotCalculations'
89
import { useLayoutMutations } from '@/renderer/core/layout/operations/layoutMutations'
@@ -3354,6 +3355,16 @@ export class LGraphNode
33543355
)
33553356
}
33563357

3358+
/**
3359+
* Get slot position using layout tree if available, fallback to node's position * Unified implementation used by both LitegraphLinkAdapter and useLinkLayoutSync
3360+
* @param slotIndex The slot index
3361+
* @param isInput Whether this is an input slot
3362+
* @returns Position of the slot center in graph coordinates
3363+
*/
3364+
getSlotPosition(slotIndex: number, isInput: boolean): Point {
3365+
return getSlotPosition(this, slotIndex, isInput)
3366+
}
3367+
33573368
/** @inheritdoc */
33583369
snapToGrid(snapTo: number): boolean {
33593370
return this.pinned ? false : snapPoint(this.pos, snapTo)

0 commit comments

Comments
 (0)