/** * Proximity component: one pointer listener per root, a lit border per target. * * @augments IvComponent */ export class Proximity extends IvComponent { /** @type {Readonly} */ static defaults: Readonly; /** * Returns the instance attached to `el`, if any. * * @param {Element} el Host element. * @returns {Proximity|undefined} The instance or `undefined`. */ static get(el: Element): Proximity | undefined; /** * Returns the existing instance or creates one. * * @param {Element} el Host element. * @param {Partial} [options] Options passed in JavaScript. * @returns {Proximity} The instance. */ static getOrCreate(el: Element, options?: Partial): Proximity; /** * Instantiates every `[data-iv-component="proximity"]` inside `root`. When * the page declares no root at all and there are `.iv-edge-near` elements, * the body becomes a generated root marked with `data-iv-auto`, which * `destroy` removes again: the effect is opt-out, like the picker (ADR-032). * * @param {ParentNode} [root] Subtree to scan. * @returns {Proximity[]} Newly created instances. */ static initAll(root?: ParentNode): Proximity[]; /** * @param {Element} el Container holding the `.iv-edge-near` elements. * @param {Partial} [options] Options passed in JavaScript. */ constructor(el: Element, options?: Partial); /** @type {Set} Elements carrying properties written here. */ _touched: Set; /** @type {Window|null} View of the element, or `null` outside a document. */ _view: Window | null; /** @type {number} Pending animation frame, `0` when there is none. */ _frame: number; /** @type {boolean} Whether a frame is scheduled. */ _pending: boolean; /** @type {number} Last pointer `clientX`. */ _x: number; /** @type {number} Last pointer `clientY`. */ _y: number; /** * Resolved options. * * @returns {Readonly} The options. */ get options(): Readonly; /** @type {HTMLElement[]|null} Targets found on the last entry. */ _cache: HTMLElement[] | null | undefined; /** * Targets of this instance: every `.iv-edge-near` in the subtree that is not * owned by a nested root. * * @returns {HTMLElement[]} The elements to light up. */ _targets(): HTMLElement[]; /** * Stores the pointer position and schedules one update per frame. * * @param {PointerEvent} event The move. * @returns {void} */ _onMove(event: PointerEvent): void; /** * Pointer gone: the glow of every touched element fades out. * * @returns {void} */ _onLeave(): void; /** * Measures every target and writes the three properties. Rectangles are * read once per frame, never per pointer event. * * @returns {void} */ _update(): void; /** * Drops any scheduled frame. * * @returns {void} */ _cancel(): void; } export type ProximityOptions = { /** * Distance in pixels at which the glow reaches zero. */ radius: number; }; import { IvComponent } from "../core/component.js";