getMouse
Category Sensors
Retrieves information about the mouse.
Demo
x : 0 y : 0
Usage
Type definitions
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/sensors/get-mouse
*/
export declare function getMouse(options?: GetMouseOptions): GetMouseReturn;
export {};