UNPKG

js.foresight

Version:

Predicts mouse trajectory to trigger actions as users approach elements, enabling anticipatory UI updates or pre-loading. Made with vanilla javascript and usable in every framework.

15 lines 918 B
import type { FocusableElement } from "tabbable"; /** * Finds the index of a focused element within a cache of tabbable elements. * It uses a predictive search for O(1) performance in the common case of * sequential tabbing, and falls back to a linear search O(n) if the * prediction fails. * * @param isReversed - True if the user is tabbing backward (Shift+Tab). * @param lastFocusedIndex - The index of the previously focused element, or null if none. * @param tabbableElementsCache - The array of all tabbable elements. * @param targetElement - The new HTML element that has received focus. * @returns The index of the targetElement in the cache, or -1 if not found. */ export declare function getFocusedElementIndex(isReversed: boolean, lastFocusedIndex: number | null, tabbableElementsCache: FocusableElement[], targetElement: HTMLElement): number; //# sourceMappingURL=getFocusedElementIndex.d.ts.map