use-resize-observer icon indicating copy to clipboard operation
use-resize-observer copied to clipboard

Future enhancement to return element coordinates

Open ritchieanesco opened this issue 1 year ago • 1 comments

Thank you for the great library!!

Just wondering if there were any plans to expose the element's x, y, top, left, etc. coordinates since you are already accessing dimensions from contentRect?

ritchieanesco avatar Jan 30 '24 02:01 ritchieanesco

You're welcome! :pray: Hmm, maybe.

Currently onResize reports width and height, and it reports the requested kind of dimensions (content- or border box size), using borderBoxSize, contentBoxSize, or the old contentRect prop.

Only contentRect has properties other than width / height, and it seems a bit accidental if I'm honest from an early implementation, as outlined in the MDN docs.

I would rather consider a lower-level implementation to hook onto, something like onEntry reporting the entire entry object itself as an escape hatch, allowing to implement something like this. :thinking:

So basically I would keep the current useResizeObserver as-is, to preserve its size observing API and optimisations, and could just add another lower-level hook called something like useResizeObserverEntry, with an onChange method :thinking:

ZeeCoder avatar Aug 21 '24 06:08 ZeeCoder