Provides an instance of ResizeObserver that can manage multiple elements and notify a wide range of ResizeObserverData.ResizeTarget listeners. Offset width and height is also provided through caching the margin and padding styles of the target element.

The action, resizeObserver, utilizes ResizeObserverManager for automatic registration and removal via Svelte.

Constructors

Methods

Constructors

Methods

  • Add an HTMLElement and ResizeObserverData.ResizeTarget instance for monitoring. Create cached style attributes for the given element include border & padding dimensions for offset width / height calculations.

    Parameters

    • el: HTMLElement

      The element to observe.

    • target: ResizeTarget

      A target that contains one of several mechanisms for updating resize data.

    Returns void

  • Clears and unobserves all currently tracked elements and managed targets.

    Returns void

  • Removes all ResizeObserverData.ResizeTarget instances for the given element from monitoring when just an element is provided otherwise removes a specific target from the monitoring map. If no more targets remain then the element is removed from monitoring.

    Parameters

    • el: HTMLElement

      Element to remove from monitoring.

    • Optionaltarget: ResizeTarget

      A specific target to remove from monitoring.

    Returns void

  • Provides a function that when invoked with an element updates the cached styles for each subscriber of the element.

    The style attributes cached to calculate offset height / width include border & padding dimensions. You only need to update the cache if you change border or padding attributes of the element.

    Parameters

    Returns void