Created
September 24, 2017 08:43
-
-
Save peterschmiz/c358a6f5069529c9557ce00e8024a3bc to your computer and use it in GitHub Desktop.
Javascript based scrollbar measurement
This file contains 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 measureScrollbar = () => { | |
const scrollDiv = document.createElement('div'); | |
let scrollbarWidth = 0; | |
scrollDiv.classList.add('scrollbar-measure'); | |
document.body.appendChild(scrollDiv); | |
scrollbarWidth = scrollDiv.offsetWidth - scrollDiv.clientWidth; | |
document.body.removeChild(scrollDiv); | |
return scrollbarWidth; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment