ResizeMonitor

Allows size monitoring of elements (or optionally a Window instance).

ResizeMonitor.addResizeListener(
  myElement,
  element => {
     console.log(element, ' changed size');
  }
);

Functions

2

Adds a resize listener to the passed element which is called when the element is resized by layout.

ParameterTypeDescription
elementHTMLElement | Document

The element to listen for resizing.

handlerResizeMonitorEventCallback

The handling function. Will be passed the element.

immediateBoolean

Pass true to have the handler called immediately when a resize is detected. The default is false to defer the call using a microtask (to batch multiple resize events).

Removes a resize listener from the passed element.

ParameterTypeDescription
elementHTMLElement | Document

The element to listen for resizing.

handlerfunction

The handling function to remove.

Typedefs

1

Resize event handing callback

ParameterTypeDescription
elementHTMLElement

Resized element

oldRectDOMRectReadOnly

Old size rectangle

newRectDOMRectReadOnly

New size rectangle