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

scrollYOffset with floating point number #1129

Closed
m-mohr opened this issue Dec 6, 2019 · 4 comments
Closed

scrollYOffset with floating point number #1129

m-mohr opened this issue Dec 6, 2019 · 4 comments

Comments

@m-mohr
Copy link
Contributor

m-mohr commented Dec 6, 2019

I've got a ReDoc instance running with scrollYOffset set to an header element. It seems that if the height of the header element is not a integer, but a floating point number the menu gets blurred a bit.

The problem occurs if you specify an element for the scrollYOffset which el.getBoundingClientRect().bottom returns a non-integer number for. It seems that in some places it works on integers and in some on floating point numbers and this leads to imprecision when calculation the scrolling position for the menu. Using Math.ceil or Math.round in normalizeScrollYOffset solved the problem for me. So I'd suggest only allowing integers as scrollYOffset and ensure in code that it is always an integer.

Hope this can be solved soon, thanks in advance!

Seems similar to #748

@RomanHotsiy
Copy link
Member

What do you mean by blurred? Could you share a screenshot?

@m-mohr
Copy link
Contributor Author

m-mohr commented Dec 13, 2019

Sure @RomanHotsiy, left is "blurred", right is "normal". Blurring only takes place after you scroll down at least one pixel.

image

Fixed it for now for me by setting scrollYOffset to () => Math.round(document.querySelector('header').getBoundingClientRect().bottom) instead of just specifying the element header. But I'm not sure whether Math.round() really works all the time, especially if the fraction is < .5. Maybe it needs to be Math.ceil(). The header has a height of 58.67... in my case and thus always rounds up so not sure about what happens when rounding down.

@m-mohr
Copy link
Contributor Author

m-mohr commented Dec 18, 2019

Interestingly, today I had a very similar issue on StackOverflow. Having seen that, I realized that this only happens in my Chrome instance, not in Firefox.

@lornajane
Copy link
Contributor

I can't replicate this problem with the current version of Redoc and this issue has been open for a while, so I'm closing it. If that seems incorrect and things still don't look right, open a new issue and let us know what version of Redoc you're using now, and what seems wrong.

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