UNPKG

common-utils-y

Version:

my common utils lib

21 lines (20 loc) 862 B
export type ParamType = { contentBoxSize: readonly ResizeObserverSize[]; contentRect: DOMRectReadOnly; borderBoxSize: readonly ResizeObserverSize[]; devicePixelContentBoxSize: readonly ResizeObserverSize[]; }; /** * 监听指定元素的尺寸变化,并在尺寸变化时触发回调函数。 * * @param {Element} el - 需要监听尺寸变化的元素。 * @param {function} callback - 当元素的尺寸发生变化时触发的回调函数。 */ export declare function addResizeObserve(el: Element, callback: (param?: ParamType) => void): void; /** * 取消监听尺寸变化的回调方法,如果不传递需要取消的回调函数,则el的回调函数全部移除 * * @param {Element} el * @param {function} callback */ export declare function removeResizeObserve(el: Element, callback?: (param?: ParamType) => void): void;