Continuously reconcile viewport focus
This commit is contained in:
parent
2c025dcfbe
commit
851f43d3d3
1 changed files with 29 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Reference in a new issue