fix: clamp stats tooltip within viewport on mobile
This commit is contained in:
@@ -74,10 +74,14 @@
|
|||||||
function updatePos(e: MouseEvent) {
|
function updatePos(e: MouseEvent) {
|
||||||
const vw = window.innerWidth;
|
const vw = window.innerWidth;
|
||||||
const vh = window.innerHeight;
|
const vh = window.innerHeight;
|
||||||
tooltipPos = {
|
const tw = 280; // matches w-[280px]
|
||||||
x: e.clientX > vw - 310 ? e.clientX - 305 : e.clientX + 14,
|
const th = 260; // approximate tooltip height
|
||||||
y: Math.min(e.clientY - 8, vh - 260),
|
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) {
|
function onCellEnter(date: string, e: MouseEvent) {
|
||||||
|
|||||||
Reference in New Issue
Block a user