isWindowFocused
Category Elements
Tracks whether the window is focused or not.
Demo
Click somewhere outside the window to lose focus
Usage
Type definitions
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/elements/is-window-focused
*/
export declare function isWindowFocused(options?: IsWindowFocusedOptions): IsWindowFocusedReturn;
export {};