mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-04-26 09:19:43 +00:00
[API] Add convenience methods to LGraphNode (#717)
- getInputOnPos - getOutputOnPos - getSlotOnPos - Follow-up on #716 - Uses more explicit names for class methods moved to module functions
This commit is contained in:
@@ -3,7 +3,7 @@ import type { LGraphNode } from "@/LGraphNode"
|
||||
|
||||
import { isInRectangle } from "@/measure"
|
||||
|
||||
export function getInputOnPos(node: LGraphNode, x: number, y: number): { index: number, input: INodeInputSlot, pos: Point } | undefined {
|
||||
export function getNodeInputOnPos(node: LGraphNode, x: number, y: number): { index: number, input: INodeInputSlot, pos: Point } | undefined {
|
||||
const { inputs } = node
|
||||
if (!inputs) return
|
||||
|
||||
@@ -28,7 +28,7 @@ export function getInputOnPos(node: LGraphNode, x: number, y: number): { index:
|
||||
}
|
||||
}
|
||||
|
||||
export function getOutputOnPos(node: LGraphNode, x: number, y: number): { index: number, output: INodeOutputSlot, pos: Point } | undefined {
|
||||
export function getNodeOutputOnPos(node: LGraphNode, x: number, y: number): { index: number, output: INodeOutputSlot, pos: Point } | undefined {
|
||||
const { outputs } = node
|
||||
if (!outputs) return
|
||||
|
||||
@@ -58,7 +58,7 @@ export function isOverNodeInput(
|
||||
canvasy: number,
|
||||
slot_pos?: Point,
|
||||
): number {
|
||||
const result = getInputOnPos(node, canvasx, canvasy)
|
||||
const result = getNodeInputOnPos(node, canvasx, canvasy)
|
||||
if (!result) return -1
|
||||
|
||||
if (slot_pos) {
|
||||
@@ -78,7 +78,7 @@ export function isOverNodeOutput(
|
||||
canvasy: number,
|
||||
slot_pos?: Point,
|
||||
): number {
|
||||
const result = getOutputOnPos(node, canvasx, canvasy)
|
||||
const result = getNodeOutputOnPos(node, canvasx, canvasy)
|
||||
if (!result) return -1
|
||||
|
||||
if (slot_pos) {
|
||||
|
||||
Reference in New Issue
Block a user