Skip to content

Commit 1761031

Browse files
committed
feat: more precise size for useMouse
1 parent 91dee93 commit 1761031

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/useMouse.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ const useMouse = (ref: RefObject<HTMLElement>): State => {
2929
cancelAnimationFrame(frame.current)
3030
frame.current = requestAnimationFrame(() => {
3131
if (ref && ref.current) {
32-
const {left, top} = ref.current.getBoundingClientRect()
32+
const {left, top, width, height} = ref.current.getBoundingClientRect()
3333
const posX = left + window.scrollX;
3434
const posY = top + window.scrollY;
3535

@@ -40,8 +40,8 @@ const useMouse = (ref: RefObject<HTMLElement>): State => {
4040
posY,
4141
elX: event.pageX - posX,
4242
elY: event.pageY - posY,
43-
elH: ref.current.offsetHeight,
44-
elW: ref.current.offsetWidth,
43+
elH: height,
44+
elW: width,
4545
});
4646
}
4747
});

0 commit comments

Comments
 (0)