mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-25 01:48:11 +08:00
Fix viewport bounds getting out of sync at times, like when toggling rulers
This commit is contained in:
@@ -0,0 +1,14 @@
|
||||
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);
|
||||
}
|
||||
Reference in New Issue
Block a user