MCPcopy Create free account
hub / github.com/Comfy-Org/litegraph.js / getSlotInPosition

Method getSlotInPosition

src/LGraphNode.ts:2008–2031  ·  view source on GitHub ↗

* @deprecated Use getSlotOnPos instead. * checks if a point is inside a node slot, and returns info about which slot * @param x * @param y * @returns if found the object contains { input|output: slot object, slot: number, link_pos: [x,y] }

(x: number, y: number)

Source from the content-addressed store, hash-verified

2006 * @returns if found the object contains { input|output: slot object, slot: number, link_pos: [x,y] }
2007 */
2008 getSlotInPosition(x: number, y: number): IFoundSlot | null {
2009 // search for inputs
2010 const { inputs, outputs } = this
2011
2012 if (inputs) {
2013 for (const [i, input] of inputs.entries()) {
2014 const pos = this.getInputPos(i)
2015 if (isInRectangle(x, y, pos[0] - 10, pos[1] - 10, 20, 20)) {
2016 return { input, slot: i, link_pos: pos }
2017 }
2018 }
2019 }
2020
2021 if (outputs) {
2022 for (const [i, output] of outputs.entries()) {
2023 const pos = this.getOutputPos(i)
2024 if (isInRectangle(x, y, pos[0] - 10, pos[1] - 10, 20, 20)) {
2025 return { output, slot: i, link_pos: pos }
2026 }
2027 }
2028 }
2029
2030 return null
2031 }
2032
2033 /**
2034 * Gets the widget on this node at the given co-ordinates.

Callers 4

processContextMenuMethod · 0.80
dropOnIoNodeMethod · 0.80
onPointerDownMethod · 0.80
onPointerDownMethod · 0.80

Calls 3

getInputPosMethod · 0.95
getOutputPosMethod · 0.95
isInRectangleFunction · 0.90

Tested by

no test coverage detected