import isBrowser from '../isBrowser';
import createElement from './createElement';
var scrollbarWidth = 0;
var scrollbarMeasure = {
    position: 'absolute',
    top: '-9999px',
    width: '50px',
    height: '50px',
    overflow: 'scroll',
};
export default function measureScrollbar() {
    if (!isBrowser) {
        return 0;
    }
    if (scrollbarWidth) {
        return scrollbarWidth;
    }
    var scrollDiv = createElement('div');
    var scrollProps = Object.keys(scrollbarMeasure);
    scrollProps.forEach(function (scrollProp) {
        scrollDiv.style[scrollProp] = scrollbarMeasure[scrollProp];
    });
    document.body.appendChild(scrollDiv);
    var width = scrollDiv.offsetWidth - scrollDiv.clientWidth;
    document.body.removeChild(scrollDiv);
    scrollbarWidth = width;
    return scrollbarWidth;
}
