From 851f43d3d3faeea6ad10e32fb77601f9039ca997 Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Sat, 23 May 2026 22:52:10 +0100 Subject: [PATCH] Continuously reconcile viewport focus --- .../src/lib/EpiphanyGraphViewer.tsx | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/web/epiphany-graph-viewer/src/lib/EpiphanyGraphViewer.tsx b/web/epiphany-graph-viewer/src/lib/EpiphanyGraphViewer.tsx index de51eaf..087741d 100644 --- a/web/epiphany-graph-viewer/src/lib/EpiphanyGraphViewer.tsx +++ b/web/epiphany-graph-viewer/src/lib/EpiphanyGraphViewer.tsx @@ -333,6 +333,35 @@ export function EpiphanyGraphViewer({ }; }); + useEffect(() => { + if (!focusSelection) { + return; + } + + let frameId = 0; + const reconcileViewportFocus = () => { + const { + activeGraphKey: currentGraphKey, + transforms: currentTransforms, + } = wheelStateRef.current; + + if (!viewportFlightRef.current) { + commitFocusFromViewport( + currentGraphKey, + currentTransforms[currentGraphKey], + undefined, + viewportFocusSelectionRef, + focusedNodeRef, + ); + } + + frameId = requestAnimationFrame(reconcileViewportFocus); + }; + + frameId = requestAnimationFrame(reconcileViewportFocus); + return () => cancelAnimationFrame(frameId); + }, [focusSelection]); + useEffect(() => { const element = viewportRef.current; const layout = visibleLayouts?.[activeGraphKey] ?? null;