mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-21 03:18:12 +08:00
15 lines
569 B
TypeScript
15 lines
569 B
TypeScript
import { type Editor } from "@graphite/wasm-communication/editor";
|
|
|
|
export function updateBoundsOfViewports(editor: Editor, container: HTMLElement) {
|
|
const viewports = Array.from(container.querySelectorAll("[data-viewport]"));
|
|
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);
|
|
}
|