This service exports functionality related to observing resized elements within a web application. It exposes a factory function, createResizeObserver()
that creates an object containing one readable signal with the real time dimensions of the observed element and a directive which will be applied on the HTML element to observe.
createResizeObserver
is a factory function that creates an object providing:
dimensions$
Readable Signal providing the real time dimensions of the observed element. The type of the object is ResizeObserverEntry. See the MDN documentationdirective
- a directive to be applied on the html element to observe. The element to observe can be passed as argument to the directive function in case it cannot be applied directly on the html element.Whenever you want to listen to dimensions changes of an element of the DOM, you can simply:
dimensions$
signal and subscribe
to it.Use the directive as method to set the element to listen.