@sv-use/core
Version:
A collection of Svelte 5 utilities.
27 lines (26 loc) • 949 B
TypeScript
import { type ConfigurableWindow } from '../__internal__/configurable.js';
import type { CleanupFunction } from '../__internal__/types.js';
interface IsWindowFocusedOptions extends ConfigurableWindow {
/**
* Whether to automatically cleanup the event listeners or not.
*
* If set to `true`, it must run in the component initialization lifecycle.
* @default true
*/
autoCleanup?: boolean;
}
type IsWindowFocusedReturn = {
readonly current: boolean;
/**
* Cleans up the event listeners.
* @note Called automatically if `options.autoCleanup` is `true`.
*/
cleanup: CleanupFunction;
};
/**
* Tracks whether the window is focused or not.
* @param options Additional options to customize the behavior.
* @see https://svelte-librarian.github.io/sv-use/docs/core/is-window-focused
*/
export declare function isWindowFocused(options?: IsWindowFocusedOptions): IsWindowFocusedReturn;
export {};