1 | import { ResizeObserverEntry } from "@juggle/resize-observer";
|
2 | import * as React from "react";
|
3 | import { AbstractPureComponent2 } from "../../common";
|
4 | export declare type ResizeSensorProps = IResizeSensorProps;
|
5 | /** @deprecated use ResizeSensorProps */
|
6 | export interface IResizeSensorProps {
|
7 | /** Contents to observe for size changes. */
|
8 | children: React.ReactNode;
|
9 | /**
|
10 | * Callback invoked when the wrapped element resizes.
|
11 | *
|
12 | * The `entries` array contains an entry for each observed element. In the
|
13 | * default case (no `observeParents`), the array will contain only one
|
14 | * element: the single child of the `ResizeSensor`.
|
15 | *
|
16 | * Note that this method is called _asynchronously_ after a resize is
|
17 | * detected and typically it will be called no more than once per frame.
|
18 | */
|
19 | onResize: (entries: ResizeObserverEntry[]) => void;
|
20 | /**
|
21 | * If `true`, all parent DOM elements of the container will also be
|
22 | * observed for size changes. The array of entries passed to `onResize`
|
23 | * will now contain an entry for each parent element up to the root of the
|
24 | * document.
|
25 | *
|
26 | * Only enable this prop if a parent element resizes in a way that does
|
27 | * not also cause the child element to resize.
|
28 | *
|
29 | * @default false
|
30 | */
|
31 | observeParents?: boolean;
|
32 | }
|
33 | /** `ResizeSensor` requires a single DOM element child and will error otherwise. */
|
34 | export declare class ResizeSensor extends AbstractPureComponent2<ResizeSensorProps> {
|
35 | static displayName: string;
|
36 | private element;
|
37 | private observer;
|
38 | render(): boolean | {} | React.ReactChild | React.ReactPortal | null | undefined;
|
39 | componentDidMount(): void;
|
40 | componentDidUpdate(prevProps: ResizeSensorProps): void;
|
41 | componentWillUnmount(): void;
|
42 | /**
|
43 | * Observe the DOM element, if defined and different from the currently
|
44 | * observed element. Pass `force` argument to skip element checks and always
|
45 | * re-observe.
|
46 | */
|
47 | private observeElement;
|
48 | private getElement;
|
49 | }
|