fix: clamp stats tooltip within viewport on mobile
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user