get-scrollbar-width

1.0.5 • Public • Published

get-scrollbar-width

Utility function to determine the scrollbar width of the current browser, returns zero if running server-side

I find this utility function particularly useful when creating a modal that blocks scrolling to determine how much padding is needed to prevent nasty jank from scrollbar removal.

var getScrollbarWidth = require('get-scrollbar-width');

var currentBrowserScrollbarWidth = getScrollbarWidth();

console.log(currentBrowserScrollbarWidth); // value depends on browser, 15 pixels is common

NPM

/get-scrollbar-width/

    Package Sidebar

    Install

    npm i get-scrollbar-width

    Weekly Downloads

    188

    Version

    1.0.5

    License

    MIT

    Unpacked Size

    3.25 kB

    Total Files

    4

    Last publish

    Collaborators

    • sirrodgepodge