Socket
Socket
Sign inDemoInstall

scrollbar-width

Package Overview
Dependencies
0
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    scrollbar-width

Calculate the width of the scrollbar in a browser window


Version published
Weekly downloads
26K
decreased by-11.9%
Maintainers
1
Install size
7.98 kB
Created
Weekly downloads
 

Readme

Source

scrollbar-width.js 3.0.0

scrollbar-width.js is a library for calculating the scrollbar size of a browser window. It is compatible with AMD, CommonJS and the standard browser environment.

Installation/Usage

AMD

Usage with AMD is straightforward:

require([
  'js/scrollbar-width'
], function(calcScrollbarWidth) {
  var scrollbarWidth = calcScrollbarWidth();
  // ...
});

Node.js

Install with npm:

npm install scrollbar-width

Then require it and call the function:

var scrollbarWidth = require("scrollbar-width")();

Bower

To install with Bower run:

bower install scrollbar-width.js

Browser

Include it in your HTML:

<script src="js/scrollbar-width.js"></script>

Then just call the function:

var scrollbarWidth = window.getScrollbarWidth();

Notes

Cached value

The function will cache the value it has calculated. You can force to calculate again by calling it with it's first parameter set to true:

var newScrollbarWidth = calcScrollbarWidth(true);

scrollbarWidth() returns null

Until the document is loaded (document.readyState !== 'loading'), scrollbarWidth() will return null. So be sure to call it when the document has loaded.

Compatibility

Tested in and compatible with:

  • Chrome
  • FireFox
  • Opera
  • IE (tested in 8+)

Issues

If you find any issues, please file an issue on the github page.

Credits

Thanks to olympicsoftware for the improved version (2.0+)

License

scrollbarWidth is licensed under the MIT license.

FAQs

Last updated on 06 May 2015

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc