-
Notifications
You must be signed in to change notification settings - Fork 98
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
feat(useMeasure): support custom measurers in order to support border-box and others #1603
base: master
Are you sure you want to change the base?
feat(useMeasure): support custom measurers in order to support border-box and others #1603
Conversation
Thanks for contribution! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
ResizeObserverEntry
matcher callback
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #1603 +/- ##
==========================================
+ Coverage 97.60% 97.80% +0.19%
==========================================
Files 63 63
Lines 1714 1868 +154
Branches 481 483 +2
==========================================
+ Hits 1673 1827 +154
Misses 39 39
Partials 2 2 ☔ View full report in Codecov by Sentry. |
What is the current behavior, and the steps to reproduce the issue?
Current implementation of the
useMeasure
hook calculates the element bounds based on content-box model only.It is a little unexpected behavior when the project and all the layout is based on border-box model and trying to calculate measures of the element has paddings.
Thus, current hook ignores paddings calculating element's width and height.
What is the expected behavior?
Giving the possibility to define custom measure matcher model to take the values needed.
How does this PR fix the problem?
By adding the additional optional function argument receives the
ResizeObserverEntry
value and returns the new measures should be applied ornull
. If function returnsnull
, the default behavior is applied and content-box measures will be returned.Checklist
useMeasure
hook elements box-sizing option #1548