Created
May 10, 2023 07:51
-
-
Save tfsojon/b00d7fb8b83e5be2b33e3c978a8bf683 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
const disableBodyScroll = () => { | |
const documentWidth = document.documentElement.clientWidth; | |
const scrollbarWidth = Math.abs(window.innerWidth - documentWidth); | |
body.style.overflowY = 'hidden'; | |
body.style.paddingRight = scrollbarWidth + "px"; | |
} | |
const enableBodyScroll = () => { | |
setTimeout(() => { | |
body.style.overflowY = ''; | |
body.style.paddingRight = ''; | |
}, 200); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment