From 7a466db2a3732bf63c6a9ac1c550e8539580554a Mon Sep 17 00:00:00 2001
From: "Thomas F. K. Jorna" <thomasfkjorna@gmail.com>
Date: Mon, 13 Sep 2021 15:36:03 +0200
Subject: feat: node scale oom invariance

---
 pages/index.tsx | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

(limited to 'pages/index.tsx')

diff --git a/pages/index.tsx b/pages/index.tsx
index b13d13f..2f3881e 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -964,17 +964,19 @@ export const Graph = forwardRef(function (props: GraphProps, graphRef: any) {
       highlightedNodes[node.id!] || previouslyHighlightedNodes[node.id!]
         ? 1 + opacity * (visuals.highlightNodeSize - 1)
         : 1
-    return basicSize * highlightSize
+    return (basicSize * highlightSize) / Math.pow(zoom, visuals.nodeZoomSize)
   }
 
   const [dragging, setDragging] = useState(false)
 
+  const [zoom, setZoom] = useState(1)
   const graphCommonProps: ComponentPropsWithoutRef<typeof TForceGraph2D> = {
     graphData: scope.nodeIds.length ? scopedGraphData : filteredGraphData,
     width: windowWidth,
     height: windowHeight,
     backgroundColor: theme.colors.gray[visuals.backgroundColor],
     warmupTicks: scope.nodeIds.length === 1 ? 100 : scope.nodeIds.length > 1 ? 20 : 0,
+    onZoom: ({ k, x, y }) => setZoom(k),
     nodeLabel: (node) => (node as OrgRoamNode).title,
     nodeColor: (node) => {
       return getNodeColor(node as OrgRoamNode)
-- 
cgit v1.2.3

