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;