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

add browser scrollbar width detection #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

seb3s
Copy link

@seb3s seb3s commented Feb 10, 2018

I've added a simple function to detect the browser scrollbar width and adapt the style offset to this exact value.

Copy link

@begrs begrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Its definetely a rough work around to attach an element to the dom to check the width but ++ for cross browser fix that should work 100% of the time.
Withouth this fix, simple scrollbar does not work properly for mobile browsers with no permanent scrollbars or Safari 11.1. (even though the docu states it should)

Copy link

@begrs begrs left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My bad for missing this in my last review:
this does not work if the script is added before the dom is loaded.

but its easy to fix:
d.addEventListener('DOMContentLoaded', function () { ss.scrollWidth = getScrollWidth(); initAll(); }); ss.initEl = initEl; ss.initAll = initAll;

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

Successfully merging this pull request may close these issues.

2 participants