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

Method recomputeInsideNodes

src/LGraphGroup.ts:240–276  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

238 }
239
240 recomputeInsideNodes(): void {
241 if (!this.graph) throw new NullGraphError()
242 const { nodes, reroutes, groups } = this.graph
243 const children = this._children
244 this._nodes.length = 0
245 children.clear()
246
247 // Move nodes we overlap the centre point of
248 for (const node of nodes) {
249 if (containsCentre(this._bounding, node.boundingRect)) {
250 this._nodes.push(node)
251 children.add(node)
252 }
253 }
254
255 // Move reroutes we overlap the centre point of
256 for (const reroute of reroutes.values()) {
257 if (isPointInRect(reroute.pos, this._bounding))
258 children.add(reroute)
259 }
260
261 // Move groups we wholly contain
262 for (const group of groups) {
263 if (containsRect(this._bounding, group._bounding))
264 children.add(group)
265 }
266
267 groups.sort((a, b) => {
268 if (a === this) {
269 return children.has(b) ? -1 : 0
270 } else if (b === this) {
271 return children.has(a) ? 1 : 0
272 } else {
273 return 0
274 }
275 })
276 }
277
278 /**
279 * Resizes and moves the group to neatly fit all given {@link objects}.

Callers 2

#processPrimaryButtonMethod · 0.80
#handleMultiSelectMethod · 0.80

Calls 6

containsCentreFunction · 0.90
isPointInRectFunction · 0.90
containsRectFunction · 0.90
addMethod · 0.80
hasMethod · 0.80
clearMethod · 0.45

Tested by

no test coverage detected