-
-
Notifications
You must be signed in to change notification settings - Fork 535
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
Cache the scrollbar width for the life of the application #373
Conversation
It changes when zooming the browser, since the physical width of the scrollbar remains the same but the physical size of a |
Although, this occurs to me now: on browsers that support |
@andersk that's right but how do you detect that support in JS? Is that even possible? |
I think we can detect if ("scrollbarWidth" in someHTMLElement.style)
… and try {
someStyleSheet.insertRule('::-webkit-scrollbar { }');
} catch (err) {
…
} |
Interesting. The stylesheet hack might be as slow as doing the detection itself no? :P |
Hey, thanks for your contribution! |
Dunno. But here’s a better idea: if we put .simplebar-content-wrapper::-webkit-scrollbar { display: none; } in if (window.getComputedStyle(contentWrapperEl, "::-webkit-scrollbar").display === "none")
…
That also seems like fair game for a vendor-prefixed feature, I guess. |
Yeah cause thing is |
But if you’re going with user-agent sniffing, that seems fine. For posterity, I note that |
Alright. I think best is to do a quick jsperf of all this 😄 |
Browsers are pretty complicated sometimes…here’s a good reference: https://gist.github.com/paulirish/5d52fb081b3570c81e3a |
Native scrollbar width should not change over the life of an application.
Cache this value to eliminate some forced reflows
See #205 and #371