mirror of
https://github.com/idanoo/GoScrobble.git
synced 2024-11-29 03:45:15 +00:00
26 lines
606 B
TypeScript
26 lines
606 B
TypeScript
|
export interface Rect {
|
||
|
width: number;
|
||
|
height: number;
|
||
|
x?: number;
|
||
|
y?: number;
|
||
|
}
|
||
|
/**
|
||
|
* Efficiently observe size changes on an element. Depends on the `ResizeObserver` api,
|
||
|
* and polyfills are needed in older browsers.
|
||
|
*
|
||
|
* ```ts
|
||
|
* const [ref, attachRef] = useCallbackRef(null);
|
||
|
*
|
||
|
* const rect = useResizeObserver(ref);
|
||
|
*
|
||
|
* return (
|
||
|
* <div ref={attachRef}>
|
||
|
* {JSON.stringify(rect)}
|
||
|
* </div>
|
||
|
* )
|
||
|
* ```
|
||
|
*
|
||
|
* @param element The DOM element to observe
|
||
|
*/
|
||
|
export default function useResizeObserver<TElement extends Element>(element: TElement | null | undefined): Rect | null;
|