From d11bad207094cf13f99cf6cf6128de1664f12e4c Mon Sep 17 00:00:00 2001
From: "Thomas F. K. Jorna" <thomasfkjorna@gmail.com>
Date: Tue, 27 Jul 2021 17:12:47 +0200
Subject: added .current to lastHoverNode references

---
 pages/index.tsx | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

(limited to 'pages/index.tsx')

diff --git a/pages/index.tsx b/pages/index.tsx
index 39e827f..1923698 100644
--- a/pages/index.tsx
+++ b/pages/index.tsx
@@ -423,7 +423,9 @@ export const Graph = function (props: GraphProps) {
         : 0
       const basicSize = 3 + links.length - (!filter.parents ? parentNeighbors : 0)
       if (physics.highlightAnim) {
-        const wasHighlightedNode = links.some((link) => isLinkRelatedToNode(link, lastHoverNode))
+        const wasHighlightedNode = links.some((link) =>
+          isLinkRelatedToNode(link, lastHoverNode.current),
+        )
         const highlightSize = highlightedNodes[node.id!]
           ? 1 + opacity * (physics.highlightNodeSize - 1)
           : lastHoverNode.current?.id! === node.id!
@@ -447,7 +449,8 @@ export const Graph = function (props: GraphProps) {
       }
       const links = linksByNodeId[node.id!] ?? []
       const wasHighlightedNode =
-        physics.highlightAnim && links.some((link) => isLinkRelatedToNode(link, lastHoverNode))
+        physics.highlightAnim &&
+        links.some((link) => isLinkRelatedToNode(link, lastHoverNode.current))
       if (globalScale <= physics.labelScale && !highlightedNodes[node.id!] && !wasHighlightedNode) {
         return
       }
@@ -506,7 +509,7 @@ export const Graph = function (props: GraphProps) {
     linkDirectionalParticles: physics.particles ? physics.particlesNumber : undefined,
     linkColor: (link) => {
       const linkIsHighlighted = isLinkRelatedToNode(link, centralHighlightedNode)
-      const linkWasHighlighted = isLinkRelatedToNode(link, lastHoverNode)
+      const linkWasHighlighted = isLinkRelatedToNode(link, lastHoverNode.current)
       if (physics.highlightAnim) {
         return linkIsHighlighted
           ? interPurple(opacity) /*the.colors.purple[500]*/
@@ -519,15 +522,13 @@ export const Graph = function (props: GraphProps) {
     },
     linkWidth: (link) => {
       const linkIsHighlighted = isLinkRelatedToNode(link, centralHighlightedNode)
-      const linkWasHighlighted = isLinkRelatedToNode(link, lastHoverNode)
+      const linkWasHighlighted = isLinkRelatedToNode(link, lastHoverNode.current)
 
       if (!physics.highlightAnim) {
         return linkIsHighlighted ? physics.linkWidth * physics.highlightLinkSize : physics.linkWidth
       }
 
-      return linkIsHighlighted
-        ? physics.linkWidth * (1 + opacity * (physics.highlightLinkSize - 1))
-        : linkWasHighlighted
+      return linkIsHighlighted || linkWasHighlighted
         ? physics.linkWidth * (1 + opacity * (physics.highlightLinkSize - 1))
         : physics.linkWidth
     },
-- 
cgit v1.2.3

