UNPKG

@material-ui/core

Version:

React components that implement Google's Material Design.

14 lines 615 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(doc) { var scrollDiv = doc.createElement('div'); scrollDiv.style.width = '99px'; scrollDiv.style.height = '99px'; scrollDiv.style.position = 'absolute'; scrollDiv.style.top = '-9999px'; scrollDiv.style.overflow = 'scroll'; doc.body.appendChild(scrollDiv); var scrollbarSize = scrollDiv.offsetWidth - scrollDiv.clientWidth; doc.body.removeChild(scrollDiv); return scrollbarSize; }