📄 usePageLeave¶
📊 Analysis Summary¶
| Metric | Count |
|---|---|
| 🔧 Functions | 2 |
| 📦 Imports | 5 |
| 📐 Interfaces | 1 |
| 📑 Type Aliases | 1 |
📚 Table of Contents¶
🛠️ File Location:¶
📂 packages/core/usePageLeave/index.ts
📦 Imports¶
| Name | Source |
|---|---|
ShallowRef |
vue |
ConfigurableWindow |
../_configurable |
shallowRef |
vue |
defaultWindow |
../_configurable |
useEventListener |
../useEventListener |
Functions¶
usePageLeave(options: UsePageLeaveOptions): UsePageLeaveReturn¶
Reactive state to show whether mouse leaves the page.
Parameters:
optionsany: No description
See: https://vueuse.org/usePageLeave
Tags: @__NO_SIDE_EFFECTS__
Raw JSDoc
Calls:
shallowRef (from vue)useEventListener (from ../useEventListener)
Internal Comments:
Code
export function usePageLeave(options: UsePageLeaveOptions = {}): UsePageLeaveReturn {
const { window = defaultWindow } = options
const isLeft = shallowRef(false)
const handler = (event: MouseEvent) => {
if (!window)
return
event = event || (window.event as any)
// @ts-expect-error missing types
const from = event.relatedTarget || event.toElement
isLeft.value = !from
}
if (window) {
const listenerOptions = { passive: true }
useEventListener(window, 'mouseout', handler, listenerOptions)
useEventListener(window.document, 'mouseleave', handler, listenerOptions)
useEventListener(window.document, 'mouseenter', handler, listenerOptions)
}
return isLeft
}
Internal helpers¶
Declared inside another function in this file.
handler(event: MouseEvent): void¶
Parameters:
eventMouseEvent
Returns: void
Internal Comments:
Code
Interfaces¶
UsePageLeaveOptions¶
Type Aliases¶
UsePageLeaveReturn¶
Generated by Syntax Scribe