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 committed Mar 25, 2019
1 parent 91dee93 commit 1761031
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 1761031

Please sign in to comment.