ResizeObserver Class

Observes the size changes of the boxes of elements (https://drafts.csswg.org/resize-observer-1/#resize-observer-interface). The observations are determined and delivered by the rendering steps of the event loop, after the layout (https://html.spec.whatwg.org/multipage/webappapis.html#update-the-rendering), so only the elements of the documents of a BrowsingContext are observed.

public sealed class ResizeObserver

Constructors

NameDescription
ResizeObserver(ResizeObserverCallback)Creates an observer that invokes the callback with the entries of the observed elements whose size changed. The observer belongs to the associated document of the current global object (the [[resizeObservers]] of the document, whose rendering steps deliver the notifications), or, without a current global object, to the document of the first observed element.

ResizeObserver(ResizeObserverCallback)

ResizeObserver.cs

Creates an observer that invokes the callback with the entries of the observed elements whose size changed. The observer belongs to the associated document of the current global object (the [[resizeObservers]] of the document, whose rendering steps deliver the notifications), or, without a current global object, to the document of the first observed element.

public ResizeObserver(ResizeObserverCallback callback)

Methods

NameDescription
Disconnect()Stops observing all the elements (https://drafts.csswg.org/resize-observer-1/#dom-resizeobserver-disconnect).
Observe(Element, ResizeObserverOptions?)Starts observing the size of an element, or changes the observed box of an observed element (https://drafts.csswg.org/resize-observer-1/#dom-resizeobserver-observe).
Unobserve(Element)Stops observing the size of an element (https://drafts.csswg.org/resize-observer-1/#dom-resizeobserver-unobserve).

Disconnect()

ResizeObserver.cs

Stops observing all the elements (https://drafts.csswg.org/resize-observer-1/#dom-resizeobserver-disconnect).

public void Disconnect()

Observe(Element, ResizeObserverOptions?)

ResizeObserver.cs

Starts observing the size of an element, or changes the observed box of an observed element (https://drafts.csswg.org/resize-observer-1/#dom-resizeobserver-observe).

public void Observe(Element target, ResizeObserverOptions? options = null)

Parameters

target Element
The element to observe.
options ResizeObserverOptions?
The box to observe (the content box by default).

See also

Unobserve(Element)

ResizeObserver.cs

Stops observing the size of an element (https://drafts.csswg.org/resize-observer-1/#dom-resizeobserver-unobserve).

public void Unobserve(Element target)