observeResize
Calls callback each time the size of element changes, with a ResizeObserver dedicated to
it. Like ResizeObserver itself, it is also called once soon after it starts observing.
To limit how often it runs, wrap the callback with debounce or throttle from
helpers4/function. Without ResizeObserver, it does nothing and returns a function that
does nothing.
Available since v3.1.5
Import
Section titled “Import”Signature
Section titled “Signature”Parameters
Section titled “Parameters”| Parameter | Type | Description |
|---|---|---|
element | Element | The element to observe |
callback | function | Receives the `ResizeObserverEntry` of `element` |
options | ObserveResizeOptions | Cancellation — see ObserveResizeOptions |
Returns
Section titled “Returns”function — A function that stops observing
Examples
Section titled “Examples”Redraw when an element is resized
Section titled “Redraw when an element is resized”The callback receives the ResizeObserverEntry of the element.
Limit how often it runs
Section titled “Limit how often it runs”Compose with debounce from helpers4/function instead of an option.
Related Types
Section titled “Related Types”ObserveResizeOptions
Section titled “ObserveResizeOptions”Options for observeResize.
