Skip to content

Instantly share code, notes, and snippets.

@wokalek
Last active November 17, 2017 20:29
Show Gist options
  • Save wokalek/46bd77a4e5b1b2dc76352b1f8061770a to your computer and use it in GitHub Desktop.
Save wokalek/46bd77a4e5b1b2dc76352b1f8061770a to your computer and use it in GitHub Desktop.
Возвращает количество пикселей ширины полосы прокрутки браузера
/**
* @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