diff options
author | Thomas F. K. Jorna <[email protected]> | 2021-07-27 18:18:38 +0200 |
---|---|---|
committer | Thomas F. K. Jorna <[email protected]> | 2021-07-27 18:18:38 +0200 |
commit | 8844a10cdd42dd39b4d4dbe058910b4612d9518c (patch) | |
tree | 64661d55ff477b388394467002c6cebfbb3560c1 /pages | |
parent | 75b71ab77b658ad68a4292a14b29fe0902038c75 (diff) |
more refactoring
Diffstat (limited to 'pages')
-rw-r--r-- | pages/index.tsx | 18 |
1 files changed, 9 insertions, 9 deletions
diff --git a/pages/index.tsx b/pages/index.tsx index c27a0a3..f35e48c 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -351,13 +351,12 @@ export const Graph = function (props: GraphProps) { const lastHoverNode = useRef<NodeObject | null>(null) useEffect(() => { - if (hoverNode) { - lastHoverNode.current = hoverNode - } if (!physics.highlightAnim) { return hoverNode ? setOpacity(1) : setOpacity(0) } - + if (hoverNode) { + lastHoverNode.current = hoverNode + } if (hoverNode) { fadeIn() } else { @@ -376,6 +375,7 @@ export const Graph = function (props: GraphProps) { () => d3int.interpolate(theme.colors.gray[500], theme.colors.gray[400]), [theme], ) + const graphCommonProps: ComponentPropsWithoutRef<typeof TForceGraph2D> = { graphData: scopedGraphData, width: windowWidth, @@ -383,12 +383,12 @@ export const Graph = function (props: GraphProps) { backgroundColor: theme.white, nodeLabel: (node) => (node as OrgRoamNode).title, nodeColor: (node) => { + const links = linksByNodeId[node.id!] ?? [] + const wasHighlightedNode = links.some((link) => + isLinkRelatedToNode(link, lastHoverNode.current), + ) if (!physics.colorful) { - return Object.keys(highlightedNodes).length === 0 - ? lastHoverNode.current?.id! === node.id! - ? interPurple(opacity) - : interGray(opacity) - : highlightedNodes[node.id!] + return wasHighlightedNode || highlightedNodes[node.id!] ? interPurple(opacity) : interGray(opacity) } |