mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-27 19:18:12 +08:00
Fix viewport bounds getting out of sync at times, like when toggling rulers
This commit is contained in:
@@ -5,7 +5,6 @@ import { type Editor } from "@graphite/wasm-communication/editor";
|
||||
import {
|
||||
defaultWidgetLayout,
|
||||
patchWidgetLayout,
|
||||
TriggerRefreshBoundsOfViewports,
|
||||
UpdateDocumentBarLayout,
|
||||
UpdateDocumentModeLayout,
|
||||
UpdateToolOptionsLayout,
|
||||
@@ -13,6 +12,7 @@ import {
|
||||
UpdateWorkingColorsLayout,
|
||||
UpdateNodeGraphBarLayout,
|
||||
TriggerGraphViewOverlay,
|
||||
TriggerDelayedZoomCanvasToFitAll,
|
||||
} from "@graphite/wasm-communication/messages";
|
||||
|
||||
// eslint-disable-next-line @typescript-eslint/explicit-function-return-type
|
||||
@@ -83,16 +83,6 @@ export function createDocumentState(editor: Editor) {
|
||||
});
|
||||
});
|
||||
|
||||
// Other
|
||||
editor.subscriptions.subscribeJsMessage(TriggerRefreshBoundsOfViewports, async () => {
|
||||
// Wait to display the unpopulated document panel (missing: tools, options bar content, scrollbar positioning, and canvas)
|
||||
await tick();
|
||||
// Wait to display the populated document panel
|
||||
await tick();
|
||||
|
||||
// Request a resize event so the viewport gets measured now that the canvas is populated and positioned correctly
|
||||
window.dispatchEvent(new CustomEvent("resize"));
|
||||
});
|
||||
// Show or hide the graph view overlay
|
||||
editor.subscriptions.subscribeJsMessage(TriggerGraphViewOverlay, (triggerGraphViewOverlay) => {
|
||||
update((state) => {
|
||||
@@ -100,6 +90,9 @@ export function createDocumentState(editor: Editor) {
|
||||
return state;
|
||||
});
|
||||
});
|
||||
editor.subscriptions.subscribeJsMessage(TriggerDelayedZoomCanvasToFitAll, () => {
|
||||
setTimeout(() => editor.handle.zoomCanvasToFitAll(), 0);
|
||||
});
|
||||
|
||||
return {
|
||||
subscribe,
|
||||
|
||||
Reference in New Issue
Block a user