UNPKG

@sv-use/core

Version:

A collection of Svelte 5 utilities.

36 lines (35 loc) 1.4 kB
import type { MaybeGetter } from '../__internal__/types.js'; type OnHoverOptions = { /** * A delay before triggering the callback. * @default undefined */ delay?: number; /** * Whether to use `mouseover` and `mouseout` events or not. * * If `false`, uses `mouseenter` and `mouseleave` events. * @default false */ dirty?: boolean; onLeave?(event: MouseEvent): void; }; type OnHoverReturn = { readonly current: boolean; }; /** * Tracks whether the given element is hovered or not. * @param element The element on which to detect the hover. * @param options Additional options to customize the behavior. * @see https://svelte-librarian.github.io/sv-use/docs/core/on-hover */ export declare function onHover(element: MaybeGetter<HTMLElement | null | undefined>, options?: OnHoverOptions): OnHoverReturn; /** * Tracks whether the given element is hovered or not and runs a callback if `true`. * @param element The element on which to detect the hover. * @param callback The callback to run if the element is hovered. * @param options Additional options to customize the behavior. * @see https://svelte-librarian.github.io/sv-use/docs/core/on-hover */ export declare function onHover(element: MaybeGetter<HTMLElement | null | undefined>, callback: (event: MouseEvent) => void, options?: OnHoverOptions): OnHoverReturn; export {};