@core-graphics/rect
Version:
JS utilities for managing rects
25 lines (24 loc) • 730 B
TypeScript
import { Rect } from "../lite";
/**
* Creates a rectangle from an HTML element
*/
export declare function fromElement(el: HTMLElement, opts?: ElementRectOptions): Rect;
export declare type ElementRectOptions = {
/**
* Whether to exclude the element's scrollbar size from the calculation.
*/
excludeScrollbar?: boolean;
/**
* Whether to exclude the element's borders from the calculation.
*/
excludeBorders?: boolean;
};
/**
* Get the rect of an element with the option to exclude the scrollbar or borders
*/
export declare function getElementRect(el: HTMLElement, opts?: ElementRectOptions): {
x: number;
y: number;
width: number;
height: number;
};