Skip to content

Commit b550e9b

Browse files
fix tooltip
1 parent a4d9304 commit b550e9b

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed

src/lib/actions/mouse-position.svelte.ts

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,12 @@ export const useMousePosition = () => {
1515
const action = (node: HTMLElement | SVGSVGElement) => {
1616
const handleMouseMove = (event: MouseEvent) => {
1717
const { clientX, clientY } = event;
18-
const tooltipWidth = 190;
19-
const rect = node.getBoundingClientRect();
20-
let tooltipX = event.clientX - rect.left + 12;
21-
22-
if (tooltipX + tooltipWidth > window.innerWidth) {
23-
tooltipX = clientX - tooltipWidth - 10;
24-
}
2518

2619
position = {
27-
x: tooltipX,
28-
y: event.clientY - rect.top + 12
20+
x: clientX - 12, // Remove rect.left
21+
y: clientY + -350 // Remove rect.top
2922
};
3023
};
31-
3224
hover(node, () => {
3325
document.addEventListener('mousemove', handleMouseMove);
3426
});

0 commit comments

Comments
 (0)