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

1px gaps due to imprecise scrollbar width calculation at non-default zoom levels #325

Closed
andersk opened this issue May 18, 2019 · 3 comments

Comments

@andersk
Copy link
Contributor

andersk commented May 18, 2019

Current Behavior

To compute the width of a scrollbar, SimpleBar uses the scrollbarwidth library, which takes offsetWidth - clientWidth of a div with a scrollbar. Since offsetWidth and clientWidth are rounded to integers and the scrollbar width isn’t always an integer at some non-default browser zoom levels, this sometimes results in weird one-pixel layout gaps.

This test case consists of red SimpleBar divs of random widths on a blue background. When rendered at certain zoom levels, white gaps are visible on the right edges of some or all of the red divs. Chrome at 200% is an especially bad case:

screenshot

Expected behavior

There should be no white gaps.

Reproducible example

https://jsfiddle.net/anderskaseorg/bhoqt7kc/

Suggested solution(s)

I sent a fix upstream to unmaintain/scrollbarWidth#2, but I’m not sure if the maintainer is active, so we may want to pull in the fixed scrollbarWidth function ourselves.

Additional context

Your environment

Software Version(s)
SimpleBar 4.0.0-alpha.9
Browser Chrome 75
Operating System Ubuntu 19.04
@andersk
Copy link
Contributor Author

andersk commented May 18, 2019

This may be the cause of #303.

@Grsmto
Copy link
Owner

Grsmto commented Jul 3, 2019

Should be fixed in 4.1.0

@gavin-murphy
Copy link

We're experiencing this issue on horizontal scroll bar in Chrome and MS Edge using latest 4.1.0

Edge appears to show approx 2 pixels of the native scroll bar.
Chrome 1px.

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