Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Future enhancement to return element coordinates #107

Open
ritchieanesco opened this issue Jan 30, 2024 · 1 comment
Open

Future enhancement to return element coordinates #107

ritchieanesco opened this issue Jan 30, 2024 · 1 comment

Comments

@ritchieanesco
Copy link

ritchieanesco commented Jan 30, 2024

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?

@ZeeCoder
Copy link
Owner

You're welcome! 🙏
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. 🤔

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 🤔

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants