react-use
react-use copied to clipboard
fix: useMeasure top/left/y/x values were always zero
Description
Fix for this issue
x
, y
, top
and left
are always 0
inside contentRect
Replace the usage of ResizeObserverEntry.contentRect
, and retrive values from ResizeObserverEntry.target.getBoundingClientRect()
https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserverEntry
Type of change
- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing functionality to not work as before)
Checklist
- [x] Read the Contributing Guide
- [x] Perform a code self-review
- [ ] Comment the code, particularly in hard-to-understand areas
- [ ] Add documentation
- [ ] Add hook's story at Storybook
- [x] Cover changes with tests
- [x] Ensure the test suite passes (
yarn test
) - [x] Provide 100% tests coverage
- [ ] Make sure code lints (
yarn lint
). Fix it withyarn lint:fix
in case of failure. - [x] Make sure types are fine (
yarn lint:types
).
Any chance to get this merged? Facing the same issue
Any news yet on when this will be merged, please? It's been over a year since the PR was submitted.
Unfortunately this repository ain't being maintained by its owner. I think this will never merge š¢
@tomasdisk It doesn't look promising, however, it looks like there has been activity within the last month or so, if you look at the commit history.
Any news? I think this is more helpful than contentRect
@streamich
contentRect does not calculate border and padding, based on MDN
I confirmed locally that the fix in this PR works. Could you consider merging it, @streamich? Iām willing to help where I can, if any help is welcomed.
Any news about this PR ? I think it would be really helpful @streamich
@nleborgne you may be interested to take a look at the better-maintained (yet awkwardly-named) https://github.com/react-hookz/web library. This one seems to be ignored by its author.
@nleborgne you may be interested to take a look at the better-maintained (yet awkwardly-named) https://github.com/react-hookz/web library. This one seems to be ignored by its author.
Thanks, I gave a quick look at the repo, it seems like the useMeasure hook only returns the width and height in the Measure object. Is there any way to access properties like top and left like in the react-use useMeasure hook?