Skip to content

Commit

Permalink
fix: Broken Tooltip. (#716)
Browse files Browse the repository at this point in the history
  • Loading branch information
antondalgren authored Jan 4, 2022
1 parent 985714d commit 9e749fc
Showing 1 changed file with 2 additions and 4 deletions.
6 changes: 2 additions & 4 deletions giraffe/src/utils/useMousePos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ interface UseMousePosProps {
const mousePositionFromEvent = (e: MouseEvent<HTMLDivElement>) => {
const {top, left} = e.currentTarget.getBoundingClientRect()

return {x: e.pageX - left, y: e.pageY - top}
return {x: e.clientX - left, y: e.clientY - top}
}

export const useMousePos = (): [MousePosition, UseMousePosProps] => {
Expand Down Expand Up @@ -50,9 +50,7 @@ export const useRefMousePos = (el: Element): MousePosition => {
}

const onMouseEnter = e => {
const {left, top} = el.getBoundingClientRect()

setState({x: e.pageX - left, y: e.pageY - top})
setState({x: e.x, y: e.y})
}

const onMouseMove = e => {
Expand Down

0 comments on commit 9e749fc

Please sign in to comment.