This commit is contained in:
Gavin McDonald
2025-04-16 16:14:03 -04:00
parent 14dc1139fb
commit 40cc0f3ab8
3 changed files with 16 additions and 8 deletions

View File

@@ -37,13 +37,17 @@ export default function Tooltip({
const handleMouseMove = (e: React.MouseEvent) => {
const { clientX: x, clientY: y } = e;
const ttWidth = ttRef.current?.offsetWidth || 0;
const ttHeight = ttRef.current?.offsetHeight || 0;
const viewportWidth = window.innerWidth - edgeBuffer;
const viewportHeight = window.innerHeight - edgeBuffer;
const ttRight = ttWidth + offsetX + x;
const ttBottom = ttHeight + offsetY + y;
const adjustment = ttBottom > viewportHeight ? ttBottom - viewportHeight : 0;
const adjustX = ttRight > viewportWidth ? ttRight - viewportWidth : 0;
const adjustY = ttBottom > viewportHeight ? ttBottom - viewportHeight : 0;
setPos({ x, y: y - adjustment });
setPos({ x: x - adjustX, y: y - adjustY });
};
const handleTouchStart = () => {