Skip to content

Commit

Permalink
fix(useMouseInElement): check if mouse out of window (#2458)
Browse files Browse the repository at this point in the history
* fix(useMouseInElement): check if mouse out of window

* Update packages/core/useMouseInElement/index.ts

---------

Co-authored-by: Anthony Fu <anthonyfu117@hotmail.com>
  • Loading branch information
chaii3 and antfu committed Jan 29, 2023
1 parent 3918340 commit 54f4e72
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/core/useMouseInElement/index.ts
Expand Up @@ -4,6 +4,7 @@ import { unrefElement } from '../unrefElement'
import type { UseMouseOptions } from '../useMouse'
import { useMouse } from '../useMouse'
import { defaultWindow } from '../_configurable'
import { useEventListener } from '../useEventListener'

export interface MouseInElementOptions extends UseMouseOptions {
handleOutside?: boolean
Expand Down Expand Up @@ -70,6 +71,10 @@ export function useMouseInElement(
},
{ immediate: true },
)

useEventListener(document, 'mouseleave', () => {
isOutside.value = true
})
}

return {
Expand Down

0 comments on commit 54f4e72

Please sign in to comment.