hasLeftPage

Category Sensors

Reactive value that tracks whether the mouse has left the page or not.

Demo

Has left page : false

Usage

<script>
	import { hasLeftPage } from '@sv-use/core';
 
	const hasLeft = hasLeftPage();
</script>
Type definitions
import { type ConfigurableWindow } from '../../__internal__/configurable.js';
import type { CleanupFunction } from '../../__internal__/types.js';
interface HasLeftPageOptions extends ConfigurableWindow {
    /**
     * Whether to automatically clean up the event listeners or not.
     *
     * If set to `true`, it must run in the component initialization lifecycle.
     * @default true
     */
    autoCleanup?: boolean;
}
type HasLeftPageReturn = {
    readonly current: boolean;
    /**
     * Cleans up the event listeners.
     * @note Is called automatically if `options.autoCleanup` is set to `true`.
     */
    cleanup: CleanupFunction;
};
/**
 * Whether the mouse has left the page or not.
 * @param options Additional options to customize the behavior.
 * @see https://svelte-librarian.github.io/sv-use/docs/core/sensors/has-left-page
 */
export declare function hasLeftPage(options?: HasLeftPageOptions): HasLeftPageReturn;
export {};

Sources