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

entries -> height returning NaN #19

Open
samdenty opened this issue Feb 26, 2019 · 6 comments
Open

entries -> height returning NaN #19

samdenty opened this issue Feb 26, 2019 · 6 comments

Comments

@samdenty
Copy link

getComputedStyle->height is returning auto in https://github.com/pelotoncycle/resize-observer/blob/9641698c8ab52ae9715f0f08884ac1aca3c4c285/src/ContentRect.ts#L20

resulting in NaN as the output. getBoundingClientRect() returns the correct boundaries for the element. I'm presuming getComputedStyle is used for performance reasons, in which case it should fallback to using getBoundingClientRect->height

@samdenty
Copy link
Author

Opened a PR here #20

@marlon-tucker
Copy link

getComputedStyle returns CSS height strings, for example 20px which is why parseFloat is failing. Unfortunately converting CSS heights into pixel values is not a trivial task..

An alternative method needs to be used for computing the content rectangle.

@devrelm
Copy link
Owner

devrelm commented Apr 1, 2019

@samdenty Thanks for opening a PR. Can you add tests to reproduce your issue? I don't doubt that it happens, but I have trouble figuring out when getComputedStyle(el).height would return 'auto'.

@samdenty
Copy link
Author

samdenty commented Apr 1, 2019

@devrelm https://stackoverflow.com/q/8628005/5269570

There are a couple of things that can cause a result of "auto". You found one of them; display: none. If an element is inline it will also return auto.

@devrelm
Copy link
Owner

devrelm commented Apr 2, 2019

Thanks!

@devrelm
Copy link
Owner

devrelm commented Apr 2, 2019

I'll have to dig more into this. The ResizeObserver algorithm for calculating box size has updated since my last update to this package, so we'll have to do another round of updates and see how it shakes out.

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

3 participants