Files
Graphite/frontend/src/utility-functions/viewports.ts
T
Timon 853c26cbc1 Desktop: Viewport bounds from viewport container (#2989)
* Remove build script because it created more issues that it solved

* Get viewport bounds from viewport container
2025-08-04 11:14:34 +00:00

15 lines
560 B
TypeScript

import { type Editor } from "@graphite/editor";
export function updateBoundsOfViewports(editor: Editor, container: HTMLElement) {
const viewports = Array.from(container.querySelectorAll("[data-viewport-container]"));
const boundsOfViewports = viewports.map((canvas) => {
const bounds = canvas.getBoundingClientRect();
return [bounds.left, bounds.top, bounds.right, bounds.bottom];
});
const flattened = boundsOfViewports.flat();
const data = Float64Array.from(flattened);
if (boundsOfViewports.length > 0) editor.handle.boundsOfViewports(data);
}