Last active
November 17, 2017 20:29
-
-
Save wokalek/46bd77a4e5b1b2dc76352b1f8061770a to your computer and use it in GitHub Desktop.
Возвращает количество пикселей ширины полосы прокрутки браузера
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
/** | |
* @returns {number} Возвращает количество пикселей ширины полосы прокрутки браузера. | |
*/ | |
static getScrollWidth() | |
{ | |
let div = document.createElement('div'); | |
div.style.display = 'inline-block'; | |
div.style.visability = 'hidden'; | |
div.style.width = '50px'; | |
div.style.height = '50px'; | |
div.style.overflowY = 'scroll'; | |
document.body.appendChild(div); | |
let scrollWidth = div.offsetWidth - div.clientWidth; | |
document.body.removeChild(div); | |
return scrollWidth; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment