UNPKG

@tldraw/editor

Version:

tldraw infinite canvas SDK (editor).

33 lines (32 loc) 1 kB
import { computed, isUninitialized } from "@tldraw/state"; function fromScratch(editor) { const shapesIds = editor.getCurrentPageShapeIds(); const viewportPageBounds = editor.getViewportPageBounds(); const notVisibleShapes2 = /* @__PURE__ */ new Set(); shapesIds.forEach((id) => { const pageBounds = editor.getShapePageBounds(id); if (pageBounds === void 0 || !viewportPageBounds.includes(pageBounds)) { notVisibleShapes2.add(id); } }); return notVisibleShapes2; } function notVisibleShapes(editor) { return computed("notVisibleShapes", function updateNotVisibleShapes(prevValue) { const nextValue = fromScratch(editor); if (isUninitialized(prevValue)) { return nextValue; } if (prevValue.size !== nextValue.size) return nextValue; for (const prev of prevValue) { if (!nextValue.has(prev)) { return nextValue; } } return prevValue; }); } export { notVisibleShapes }; //# sourceMappingURL=notVisibleShapes.mjs.map