|
|
|
@ -165,13 +165,23 @@ const FlameGraph = ({ |
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
if (barIndex !== -1 && !isNaN(levelIndex) && !isNaN(barIndex)) { |
|
|
|
|
tooltipRef.current.style.top = e.clientY + 'px'; |
|
|
|
|
if (document.documentElement.clientWidth - e.clientX < 400) { |
|
|
|
|
tooltipRef.current.style.right = document.documentElement.clientWidth - e.clientX + 15 + 'px'; |
|
|
|
|
tooltipRef.current.style.left = 'auto'; |
|
|
|
|
// tooltip has a set number of lines of text so 200 should be good enough (with some buffer) without going
|
|
|
|
|
// into measuring rendered sizes
|
|
|
|
|
if (e.clientY < document.documentElement.clientHeight - 200) { |
|
|
|
|
tooltipRef.current.style.top = e.clientY + 'px'; |
|
|
|
|
tooltipRef.current.style.bottom = 'auto'; |
|
|
|
|
} else { |
|
|
|
|
tooltipRef.current.style.bottom = document.documentElement.clientHeight - e.clientY + 'px'; |
|
|
|
|
tooltipRef.current.style.top = 'auto'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
// 400 is max width of the tooltip
|
|
|
|
|
if (e.clientX < document.documentElement.clientWidth - 400) { |
|
|
|
|
tooltipRef.current.style.left = e.clientX + 15 + 'px'; |
|
|
|
|
tooltipRef.current.style.right = 'auto'; |
|
|
|
|
} else { |
|
|
|
|
tooltipRef.current.style.right = document.documentElement.clientWidth - e.clientX + 15 + 'px'; |
|
|
|
|
tooltipRef.current.style.left = 'auto'; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
setTooltipItem(levels[levelIndex][barIndex]); |
|
|
|
|