UNPKG

@material-ui/core

Version:

React components that implement Google's Material Design.

14 lines 631 B
// A change of the browser zoom change the scrollbar size. // Credit https://github.com/twbs/bootstrap/blob/3ffe3a5d82f6f561b82ff78d82b32a7d14aed558/js/src/modal.js#L512-L519 export default function getScrollbarSize() { const scrollDiv = document.createElement('div'); scrollDiv.style.width = '99px'; scrollDiv.style.height = '99px'; scrollDiv.style.position = 'absolute'; scrollDiv.style.top = '-9999px'; scrollDiv.style.overflow = 'scroll'; document.body.appendChild(scrollDiv); const scrollbarSize = scrollDiv.offsetWidth - scrollDiv.clientWidth; document.body.removeChild(scrollDiv); return scrollbarSize; }