diff options
author | Thomas F. K. Jorna <[email protected]> | 2021-07-27 22:21:48 +0200 |
---|---|---|
committer | Thomas F. K. Jorna <[email protected]> | 2021-07-27 22:21:48 +0200 |
commit | e798207a8e380e7d8c19a0bfbaea5083d9365184 (patch) | |
tree | 92c68788f5681a44b36e08cf698e7dd21eb701e3 /pages | |
parent | 1a7e8842d71a47e71fcaa1fea004b473f9799fe9 (diff) |
added build files to repo
Diffstat (limited to 'pages')
-rw-r--r-- | pages/index.tsx | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/pages/index.tsx b/pages/index.tsx index 34fa3f4..7ac12cd 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -351,12 +351,12 @@ export const Graph = function (props: GraphProps) { const lastHoverNode = useRef<NodeObject | null>(null) useEffect(() => { - if (!physics.highlightAnim) { - return hoverNode ? setOpacity(1) : setOpacity(0) - } if (hoverNode) { lastHoverNode.current = hoverNode } + if (!physics.highlightAnim) { + return hoverNode ? setOpacity(1) : setOpacity(0) + } if (hoverNode) { fadeIn() } else { @@ -391,7 +391,7 @@ export const Graph = function (props: GraphProps) { ...previouslyHighlightedLinks.flatMap((link) => [link.source, link.target]), ].map((nodeId) => [nodeId, {}]), ), - [hoverNode], + [hoverNode, previouslyHighlightedLinks, lastHoverNode], ) const graphCommonProps: ComponentPropsWithoutRef<typeof TForceGraph2D> = { @@ -453,9 +453,7 @@ export const Graph = function (props: GraphProps) { return } const links = linksByNodeId[node.id!] ?? [] - const wasHighlightedNode = links.some((link) => - isLinkRelatedToNode(link, lastHoverNode.current), - ) + const wasHighlightedNode = previouslyHighlightedNodes[node.id!] if ( (globalScale <= physics.labelScale || physics.labels === 1) && @@ -485,9 +483,10 @@ export const Graph = function (props: GraphProps) { if (globalScale <= physics.labelScale) { return opacity } + return highlightedNodes[node.id!] || previouslyHighlightedNodes[node.id!] - ? 1 * fadeFactor * (-1 * (0.5 * opacity - 1)) - : 1 + ? Math.max(fadeFactor, opacity) + : 1 * fadeFactor * (-1 * (0.5 * opacity - 1)) } if (physics.labels === 2 && (wasHighlightedNode || highlightedNodes[node.id!])) { const backgroundOpacity = 0.5 * getLabelOpacity() |