@tldraw/editor
Version:
tldraw infinite canvas SDK (editor).
53 lines (52 loc) • 1.97 kB
JavaScript
;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var notVisibleShapes_exports = {};
__export(notVisibleShapes_exports, {
notVisibleShapes: () => notVisibleShapes
});
module.exports = __toCommonJS(notVisibleShapes_exports);
var import_state = require("@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 (0, import_state.computed)("notVisibleShapes", function updateNotVisibleShapes(prevValue) {
const nextValue = fromScratch(editor);
if ((0, import_state.isUninitialized)(prevValue)) {
return nextValue;
}
if (prevValue.size !== nextValue.size) return nextValue;
for (const prev of prevValue) {
if (!nextValue.has(prev)) {
return nextValue;
}
}
return prevValue;
});
}
//# sourceMappingURL=notVisibleShapes.js.map