Skip to content

Commit

Permalink
fix: modify the tooltip update conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
jinoosss committed Aug 22, 2024
1 parent 46b025a commit e512870
Showing 1 changed file with 13 additions and 13 deletions.
26 changes: 13 additions & 13 deletions packages/web/src/components/common/pool-graph/PoolGraph.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -207,9 +207,6 @@ const PoolGraph: React.FC<PoolGraphProps> = ({
if (mouseY < 0.000001 || mouseY > height) {
return false;
}
if (bin.reserveTokenMap < 0 || !bin.reserveTokenMap) {
return false;
}
const isHoveringCurrentBin = document
.getElementById(getBinId(bin.index))
?.matches(":hover");
Expand All @@ -235,25 +232,28 @@ const PoolGraph: React.FC<PoolGraphProps> = ({
return bin.index === hoveredBinIndex;
});

if (currentBin?.index) {
if (currentBin.index !== lastHoverBinIndexRef.current) {
lastHoverBinIndexRef.current = currentBin.index;
} else {
setPositionX(mouseX);
setPositionY(mouseY);
return;
}
}

if (!currentBin) {
lastHoverBinIndexRef.current = -1;
setPositionX(null);
setPositionY(null);

if (!nextSpacing) {
setTooltipInfo(null);
}
return;
}

// Only updates the position when the hovered area is the same bar and has tooltip information.
if (currentBin.index === lastHoverBinIndexRef.current) {
if (tooltipInfo) {
setPositionX(mouseX);
setPositionY(mouseY);
return;
}
}

lastHoverBinIndexRef.current = currentBin.index;

if (
Math.abs(height - mouseY - 0.0001) >
boundsHeight -
Expand Down

0 comments on commit e512870

Please sign in to comment.