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

Consider floating point widths and heights of parent node #1610

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

delijah
Copy link

@delijah delijah commented Nov 6, 2020

In some cases (like having a dynamic grid layout on the page) parent nodes have floating point widths and heights. offsetWidth and offsetHeight does not consider this, it just delivers integers. This results in wrong layouting. getBoundingClientRect considers floating point values, and therefore fixes the wrong layouting.

Sidenote: According to some research i've done, getBoundingClientRect returns the same values for width and height as offsetWidth and offsetHeight, except for the case when a parent node uses transform: scale(...).

@delijah delijah force-pushed the floating-point-width-and-height branch from a62be17 to 06f0173 Compare November 6, 2020 12:46
@delijah
Copy link
Author

delijah commented Nov 6, 2020

Thinking about adding a fallback to offsetWidth and offsetHeight for older browsers ... 🤔

What do you think?

https://caniuse.com/getboundingclientrect

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