stuart-b
8/8/2017 - 9:04 AM

Calculate width of scrollbar for use with 100vw issues

Calculate width of scrollbar for use with 100vw issues

getScrollBarWidth () {

        const $body       = $('body');
        const windowWidth = window.innerWidth;

        if ($body.prop('scrollHeight') > window.innerHeight) {
            // Magic number to stop Chrome doing stupid stuff with sub-pixel widths
            return windowWidth - $body.width() + 1;
        }

        return 0;
},