Skip to content

Commit b879cba

Browse files
comfy-pr-botniknah
andauthored
[backport core/1.32] Expose LGraphNode.getSlotPosition (#7057)
Backport of #7042 to `core/1.32` Automatically created by backport workflow. ┆Issue is synchronized with this [Notion page](https://www.notion.so/PR-7057-backport-core-1-32-Expose-LGraphNode-getSlotPosition-2bb6d73d365081bc86e5c4e7a13503e3) by [Unito](https://www.unito.io) Co-authored-by: niknah <niknah+github@gmail.com>
1 parent 50254d1 commit b879cba

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'
@@ -3340,6 +3341,16 @@ export class LGraphNode
33403341
)
33413342
}
33423343

3344+
/**
3345+
* Get slot position using layout tree if available, fallback to node's position * Unified implementation used by both LitegraphLinkAdapter and useLinkLayoutSync
3346+
* @param slotIndex The slot index
3347+
* @param isInput Whether this is an input slot
3348+
* @returns Position of the slot center in graph coordinates
3349+
*/
3350+
getSlotPosition(slotIndex: number, isInput: boolean): Point {
3351+
return getSlotPosition(this, slotIndex, isInput)
3352+
}
3353+
33433354
/** @inheritdoc */
33443355
snapToGrid(snapTo: number): boolean {
33453356
return this.pinned ? false : snapPoint(this.pos, snapTo)

0 commit comments

Comments
 (0)