UNPKG

@sv-use/core

Version:

A collection of Svelte 5 utilities.

42 lines (41 loc) 1.19 kB
import type { CleanupFunction } from '../__internal__/types.js'; type GetMouseOptions = { /** * Whether to auto-cleanup the event listener or not. * * If set to `true`, it must run in the component initialization lifecycle. * @default true */ autoCleanup?: boolean; /** * The initial position of the mouse. * @default { x: 0; y: 0 } */ initial?: { x: number; y: number; }; /** * A callback for when the mouse moves. * @default () => {} */ onMove?: (event: MouseEvent) => void; }; type GetMouseReturn = { /** The horizontal position of the mouse. */ readonly x: number; /** The vertical position of the mouse. */ readonly y: number; /** * Cleans up the event listener. * @note Is called automatically if `options.autoCleanup` is set to `true`. */ cleanup: CleanupFunction; }; /** * Retrieves information about the mouse. * @param options Additional options to customize the behavior. * @see https://svelte-librarian.github.io/sv-use/docs/core/get-mouse */ export declare function getMouse(options?: GetMouseOptions): GetMouseReturn; export {};