Skip to content

Commit

Permalink
feat: more precise size for useMouse
Browse files Browse the repository at this point in the history
  • Loading branch information
ShizukuIchi authored and streamich committed Mar 26, 2019
1 parent ec30e92 commit b887075
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/useMouse.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ const useMouse = (ref: RefObject<HTMLElement>): State => {
cancelAnimationFrame(frame.current)
frame.current = requestAnimationFrame(() => {
if (ref && ref.current) {
const {left, top} = ref.current.getBoundingClientRect()
const {left, top, width, height} = ref.current.getBoundingClientRect()
const posX = left + window.scrollX;
const posY = top + window.scrollY;

Expand All @@ -40,8 +40,8 @@ const useMouse = (ref: RefObject<HTMLElement>): State => {
posY,
elX: event.pageX - posX,
elY: event.pageY - posY,
elH: ref.current.offsetHeight,
elW: ref.current.offsetWidth,
elH: height,
elW: width,
});
}
});
Expand Down

0 comments on commit b887075

Please sign in to comment.