diff options
author | Kirill Rogovoy <[email protected]> | 2021-07-23 10:14:23 +0300 |
---|---|---|
committer | Kirill Rogovoy <[email protected]> | 2021-07-23 10:14:23 +0300 |
commit | b8c58914cc1e251ce161905340647b6824d0a7c4 (patch) | |
tree | da336870a635974ed3cfea761c39e4441f1ecd85 /pages/index.tsx | |
parent | 55a08bc5e756f12012fc0eafc807e5fe259c171a (diff) |
Add zoomToFit when the list of rendered nodes changes
Diffstat (limited to 'pages/index.tsx')
-rw-r--r-- | pages/index.tsx | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/pages/index.tsx b/pages/index.tsx index 8dcd21e..c278394 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -628,6 +628,16 @@ export const Graph = function (props: GraphProps) { [scope], ) + // make sure the camera position and zoom or fine when the list of nodes to render is changed + useEffect(() => { + // this setTimeout was added holistically because the behavior is better when we put + // zoomToFit off a little bit + setTimeout(() => { + const fg = threeDim ? graph3dRef.current : graph2dRef.current + fg?.zoomToFit(0, 200) + }, 1) + }, [JSON.stringify(scopedNodeIds)]) + useEffect(() => { ;(async () => { const fg = threeDim ? graph3dRef.current : graph2dRef.current |