mirror of
https://github.com/Comfy-Org/ComfyUI_frontend.git
synced 2026-02-03 22:59:14 +00:00
Snap everything to grid (#315)
* Implement snap to grid - Moves positioning logic to LGraph - Simplifies code - Adds Pointer API to alt-clone node - Removes always_round_positions, replaced by always snap to grid (default size is 1 when always snapping) Fix refator error * Fix group items snapped without group * Allow snapping of all items - Add snapToGrid to Positionable - Impl. on all types - Deprecated: alignToGrid is now a wrapper * Fix test import alias, update expectations * Prevent desync of before / after change events Adds ability to perform late binding of finally() during drag start. * nit - Refactor * Fix unwanted snap on node/group add * nit - Doc * Add shift key state tracking for snap to grid Private impl., no state API as yet. * Add snap guides rendering Nodes, reroutes * Optimisation - reroute rendering Fixes exponential redraw * Add snap guidelines for groups
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import type { Parent } from "../interfaces"
|
||||
import type { Parent, Positionable } from "../interfaces"
|
||||
import { LGraphNode } from "@/LGraphNode"
|
||||
|
||||
/**
|
||||
* Creates a flat set of all items by recursively iterating through all child items.
|
||||
@@ -16,3 +17,14 @@ export function getAllNestedItems<TParent extends Parent<TParent>>(items: Readon
|
||||
item.children?.forEach(x => addRecursively(x, flatSet))
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Iterates through a collection of {@link Positionable} items, returning the first {@link LGraphNode}.
|
||||
* @param items The items to search through
|
||||
* @returns The first node found in {@link items}, otherwise `undefined`
|
||||
*/
|
||||
export function findFirstNode(items: Iterable<Positionable>): LGraphNode | undefined {
|
||||
for (const item of items) {
|
||||
if (item instanceof LGraphNode) return item
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user