@farris/ui-vue
Version:
Farris Vue, a Farris Design based Vue3 component library.
26 lines (25 loc) • 1.1 kB
TypeScript
/**
* 测量 Popover 挂载宿主的几何信息。
*
* Teleport to="body" 在京东 micro-app 等场景会落到 micro-app-body,
* 不能再把 body 当成视口原点 (0,0)。统一用真实 DOM 的 getBoundingClientRect。
*
* 定位公式配合:left/top = referenceRect - hostRect + hostScroll
* (两侧矩形都是视口坐标,差值为相对宿主坐标;滚动取宿主自身 scroll,不再叠加 documentElement)
*/
export interface HostMetrics {
left: number;
top: number;
width: number;
height: number;
bottom: number;
scrollLeft: number;
scrollTop: number;
}
/**
* host 声明为 any,调用方可能传入元素、选择器字符串,或(在 JSX 中)传入 Ref。
* 非元素值会直接进入 `<Teleport to>`,故统一归一化并回退到 body。
*/
export declare function resolveHostTarget(host: any): HTMLElement | 'body';
export declare function getHostElement(host: HTMLElement | 'body'): HTMLElement | null;
export declare function measureHost(host: HTMLElement | 'body', rightBoundary?: HTMLElement | null): HostMetrics;