Skip to content

Commit

Permalink
fix(useMouseInElement): optimize outside computation (#3380)
Browse files Browse the repository at this point in the history
Co-authored-by: fengmingjian <fmj@hanzhisoft.com>
Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
3 people committed Nov 9, 2023
1 parent 1aa50f8 commit 7c88d81
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/core/useMouseInElement/index.ts
Expand Up @@ -25,6 +25,8 @@ export function useMouseInElement(
handleOutside = true,
window = defaultWindow,
} = options
const type = options.type || 'page'

const { x, y, sourceType } = useMouse(options)

const targetRef = ref(target ?? window?.document.body)
Expand Down Expand Up @@ -53,8 +55,8 @@ export function useMouseInElement(
height,
} = el.getBoundingClientRect()

elementPositionX.value = left + window.pageXOffset
elementPositionY.value = top + window.pageYOffset
elementPositionX.value = left + (type === 'page' ? window.pageXOffset : 0)
elementPositionY.value = top + (type === 'page' ? window.pageYOffset : 0)
elementHeight.value = height
elementWidth.value = width

Expand Down

0 comments on commit 7c88d81

Please sign in to comment.