summaryrefslogtreecommitdiff
path: root/pages/index.tsx
diff options
context:
space:
mode:
authorThomas F. K. Jorna <[email protected]>2021-09-13 15:36:03 +0200
committerThomas F. K. Jorna <[email protected]>2021-09-13 15:36:03 +0200
commit7a466db2a3732bf63c6a9ac1c550e8539580554a (patch)
tree29947d6e47c957bfb8f76d7adaf29472b06d4cac /pages/index.tsx
parentb07e23ab05f1ad68b94f58a748dd18d351143056 (diff)
feat: node scale oom invariance
Diffstat (limited to 'pages/index.tsx')
-rw-r--r--pages/index.tsx4
1 files changed, 3 insertions, 1 deletions
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)