JavaScripture
Contribute via GitHub Feedback

ResizeObserver : Object

ResizeObserver allows you to provide a function that is called asynchronously when the size of observed elements change.

Constructors

new ResizeObserver(callback : Function) : ResizeObserver
callback(entries : Array<ResizeObserverEntry>, observer : ResizeObserver) : undefined

Creates a new ResizeObserver that will call callback when the size of elements passed to observe() change. Note that callback will be called at some time after the current script that causes the resize completes. The observer passed to callback is the newly created ResizeObserver.

Example:

Run

Results:

 

Instance Methods

disconnect() : undefined

Unhooks this observer from all targets specified in previous observe() calls.

Example:

Run

Results:

 

observe(target : Element) : undefined

Registers the observer to be called any time the specified element's size changes. If observe() is called more than once, it will listen to changes on each target.

Example:

Run

Results:

 

unobserve(target : Element) : undefined

Removes target from the list of observer elements.

Example:

Run

Results: