ResizeObserver (utils/dom)
@ckeditor/ckeditor5-utils/src/dom/resizeobserver
A helper class which instances allow performing custom actions when native DOM elements are resized.
By default, it uses the native DOM resize observer under the hood and in browsers that do not support the native API yet, a polyfilled observer is used instead.
Filtering
Properties
-
_callback : function
private readonly
The callback executed each time
_element
is resized. -
_element : HTMLElement
private readonly
The element observer by this observer.
Static properties
-
_observerInstance
protected readonly static
The single native observer instance (or polyfill in browsers that do not support the API) shared across all
ResizeObserver
instances. -
_elementCallbacks
private readonly static
A mapping of native DOM elements and their callbacks shared across all
ResizeObserver
instances.
Methods
-
constructor( element, callback )
Creates an instance of the
ResizeObserver
class.Parameters
element : HTMLElement
A DOM element that is to be observed for resizing. Note that the element must be visible (i.e. not detached from DOM) for the observer to work.
callback : function
A function called when the observed element was resized. It passes the
ResizeObserverEntry
object with information about the resize event.
-
destroy()
Destroys the observer which disables the
callback
passed to theconstructor
.
Static methods
-
_addElementCallback( element, callback )
private static
Registers a new resize callback for the DOM element.
Parameters
element : HTMLElement
callback : function
-
_createObserver()
private static
Creates the single native observer shared across all
ResizeObserver
instances. If the browser does not support the native API, it creates a polyfill. -
_deleteElementCallback( element, callback )
private static
Removes a resize callback from the DOM element. If no callbacks are left for the element, it removes the element from the native observer.
Parameters
element : HTMLElement
callback : function
-
_getElementCallbacks( element ) → Set.<HTMLElement> | null
private static
Returns are registered resize callbacks for the DOM element.
Parameters
element : HTMLElement
Returns
Set.<HTMLElement> | null
Every day, we work hard to keep our documentation complete. Have you spotted an outdated information? Is something missing? Please report it via our issue tracker.