diff --git a/src/LGraphCanvas.ts b/src/LGraphCanvas.ts index 1efd11fd6..b1e1712d7 100644 --- a/src/LGraphCanvas.ts +++ b/src/LGraphCanvas.ts @@ -2650,7 +2650,7 @@ export class LGraphCanvas { const deltaX = delta[0] / this.ds.scale const deltaY = delta[1] / this.ds.scale for (const item of allItems) { - if (!item.pinned) item.move(deltaX, deltaY, true) + item.move(deltaX, deltaY, true) } this.#dirty() diff --git a/src/utils/collections.ts b/src/utils/collections.ts index 87d0aa02c..8a25ff0f3 100644 --- a/src/utils/collections.ts +++ b/src/utils/collections.ts @@ -1,18 +1,20 @@ -import type { Parent, Positionable } from "../interfaces" +import type { Positionable } from "../interfaces" import { LGraphNode } from "@/LGraphNode" /** - * Creates a flat set of all items by recursively iterating through all child items. + * Creates a flat set of all positionable items by recursively iterating through all child items. + * + * Does not include or recurse into pinned items. * @param items The original set of items to iterate through - * @returns All items in the original set, and recursively, their children + * @returns All unpinned items in the original set, and recursively, their children */ -export function getAllNestedItems>(items: ReadonlySet): Set { - const allItems = new Set() +export function getAllNestedItems(items: ReadonlySet): Set { + const allItems = new Set() items?.forEach(x => addRecursively(x, allItems)) return allItems - function addRecursively(item: TParent, flatSet: Set): void { - if (flatSet.has(item)) return + function addRecursively(item: Positionable, flatSet: Set): void { + if (flatSet.has(item) || item.pinned) return flatSet.add(item) item.children?.forEach(x => addRecursively(x, flatSet)) }