MCPcopy
hub / github.com/malte-wessel/react-custom-scrollbars / getScrollbarWidth

Function getScrollbarWidth

src/utils/getScrollbarWidth.js:4–24  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2let scrollbarWidth = false;
3
4export default function getScrollbarWidth() {
5 if (scrollbarWidth !== false) return scrollbarWidth;
6 /* istanbul ignore else */
7 if (typeof document !== 'undefined') {
8 const div = document.createElement('div');
9 css(div, {
10 width: 100,
11 height: 100,
12 position: 'absolute',
13 top: -9999,
14 overflow: 'scroll',
15 MsOverflowStyle: 'scrollbar'
16 });
17 document.body.appendChild(div);
18 scrollbarWidth = (div.offsetWidth - div.clientWidth);
19 document.body.removeChild(div);
20 } else {
21 scrollbarWidth = 0;
22 }
23 return scrollbarWidth || 0;
24}

Callers 5

browser.spec.jsFile · 0.85
addListenersMethod · 0.85
removeListenersMethod · 0.85
_updateMethod · 0.85
renderMethod · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…