Class ComponentSizeObserver

java.lang.Object
com.vaadin.flow.component.internal.ComponentSizeObserver
All Implemented Interfaces:
Serializable

public class ComponentSizeObserver extends Object implements Serializable
Per-UI shared ResizeObserver manager that tracks component sizes using a single browser ResizeObserver instance.

One instance is created per UI, lazily via get(UI) when the first component's size is observed. A single browser ResizeObserver is used to track all observed elements, dispatching a custom "vaadin-component-resize" event on the UI element with aggregated size data.

For internal use only. May be renamed or removed in a future release.

See Also:
  • Method Details

    • get

      public static ComponentSizeObserver get(UI ui)
      Returns the ComponentSizeObserver for the given UI, creating it lazily.
      Parameters:
      ui - the UI to get the observer for
      Returns:
      the observer instance
    • observe

      public void observe(Element element, ValueSignal<Component.Size> signal)
      Starts observing the given element and updates the signal with size changes.
      Parameters:
      element - the element to observe
      signal - the signal to update
    • unobserve

      public void unobserve(ValueSignal<Component.Size> signal)
      Stops observing the component associated with the given signal.
      Parameters:
      signal - the signal whose component should stop being observed