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

useLockBodyScroll: add padding to the body as well with overflow hidden #324

Open
ike-gg opened this issue Dec 17, 2024 · 1 comment
Open

Comments

@ike-gg
Copy link

ike-gg commented Dec 17, 2024

currently, when using the useLockBodyScroll hook, you may experience layout shifting when switching the value of the overflow property

to avoid this, you should also add padding-right to the body element to prevent shifting- 15px should be fine in most cases

perhaps consider adding this as an optional feature (as well with the value of the padding) as a prop to the hook?

@sagarpanchal
Copy link

currently, when using the useLockBodyScroll hook, you may experience layout shifting when switching the value of the overflow property

to avoid this, you should also add padding-right to the body element to prevent shifting- 15px should be fine in most cases

perhaps consider adding this as an optional feature (as well with the value of the padding) as a prop to the hook?

@ike-gg If the operating system or browser has overlay scrollbars (or it is a mobile browser with no scrollbars) then the adding the padding-right would cause layout shift/resize. So, it is not a general solution that would work everywhere.

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

2 participants