diff --git a/site/src/components/StatsView.svelte b/site/src/components/StatsView.svelte index 78b052d..5c9386a 100644 --- a/site/src/components/StatsView.svelte +++ b/site/src/components/StatsView.svelte @@ -74,10 +74,14 @@ function updatePos(e: MouseEvent) { const vw = window.innerWidth; const vh = window.innerHeight; - tooltipPos = { - x: e.clientX > vw - 310 ? e.clientX - 305 : e.clientX + 14, - y: Math.min(e.clientY - 8, vh - 260), - }; + const tw = 280; // matches w-[280px] + const th = 260; // approximate tooltip height + const gap = 14; + let x = e.clientX + gap; + if (x + tw > vw) x = e.clientX - gap - tw; + x = Math.max(4, Math.min(x, vw - tw - 4)); + const y = Math.max(4, Math.min(e.clientY - 8, vh - th - 4)); + tooltipPos = { x, y }; } function onCellEnter(date: string, e: MouseEvent) {