UNPKG

customerio-gist-web

Version:

Build beautiful in-app flows with no code and deliver them instantly to your app. http://customer.io

31 lines (30 loc) 1.66 kB
export type TooltipPosition = 'top' | 'bottom' | 'left' | 'right'; export declare function findTargetElement(selector: string): Element | null; export interface TooltipHandle { cleanup: () => void; reposition: () => void; } export interface PositionTooltipOptions { /** * Called when the position manager detects that the target or tooltip element * was removed from the DOM unexpectedly (e.g. SPA navigation, dynamic DOM * mutation). Not called when the consumer invokes `handle.cleanup()` directly. */ onDetach?: () => void; } /** * Predicts whether the tooltip can be positioned after the target is scrolled * into view. Returns true only when the target exists in the DOM and at least * one placement (preferred + fallbacks) would fit the viewport assuming the * target occupies a centered viewport position after scrollIntoView. */ export declare function canTooltipFitInViewport(tooltipElement: HTMLElement, targetSelector: string, position: TooltipPosition): boolean; /** * If the target is already visible, resolves immediately. * Otherwise, if `canTooltipFitInViewport` predicts a valid placement, smoothly * scrolls the target into view (including within nested scroll containers) and * waits for the scroll to settle. Returns false without scrolling when the * preflight fails. */ export declare function ensureTargetInView(tooltipElement: HTMLElement, targetSelector: string, position: TooltipPosition): Promise<boolean>; export declare function positionTooltip(tooltipElement: HTMLElement, targetSelector: string, position: TooltipPosition, options?: PositionTooltipOptions): TooltipHandle | null;