Skip to content

Commit

Permalink
fix(useMouseInElement) isOutside is true for detached elements (#1614) (
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Agafonov committed May 22, 2022
1 parent 6d20309 commit ebd60af
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions packages/core/useMouseInElement/index.ts
Expand Up @@ -33,7 +33,7 @@ export function useMouseInElement(
const elementPositionY = ref(0)
const elementHeight = ref(0)
const elementWidth = ref(0)
const isOutside = ref(false)
const isOutside = ref(true)

let stop = () => {}

Expand All @@ -59,7 +59,9 @@ export function useMouseInElement(

const elX = x.value - elementPositionX.value
const elY = y.value - elementPositionY.value
isOutside.value = elX < 0 || elY < 0 || elX > elementWidth.value || elY > elementHeight.value
isOutside.value = width === 0 || height === 0
|| elX < 0 || elY < 0
|| elX > width || elY > height

if (handleOutside || !isOutside.value) {
elementX.value = elX
Expand Down

0 comments on commit ebd60af

Please sign in to comment.