@bnidev/js-utils
    Preparing search index...

    Function onElementResize

    • Observes size changes on a specific HTML element using ResizeObserver.

      Parameters

      • element: HTMLElement

        The target HTML element to observe.

      • callback: (entry: ResizeObserverEntry) => void

        Called with a ResizeObserverEntry when the element resizes.

      Returns () => void

      A cleanup function to disconnect the observer.

      const box = document.querySelector('#box')!
      const stop = onElementResize(box, (entry) => {
      console.log('Element resized:', entry.contentRect)
      })

      // Later, to stop observing:
      stop()