MCPcopy Index your code
hub / github.com/shipshapecode/tether / getScrollBarSize

Function getScrollBarSize

src/js/utils/general.js:21–59  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

19}
20
21export function getScrollBarSize() {
22 if (_scrollBarSize) {
23 return _scrollBarSize;
24 }
25 const inner = document.createElement('div');
26 inner.style.width = '100%';
27 inner.style.height = '200px';
28
29 const outer = document.createElement('div');
30 extend(outer.style, {
31 position: 'absolute',
32 top: 0,
33 left: 0,
34 pointerEvents: 'none',
35 visibility: 'hidden',
36 width: '200px',
37 height: '150px',
38 overflow: 'hidden'
39 });
40
41 outer.appendChild(inner);
42
43 document.body.appendChild(outer);
44
45 const widthContained = inner.offsetWidth;
46 outer.style.overflow = 'scroll';
47 let widthScroll = inner.offsetWidth;
48
49 if (widthContained === widthScroll) {
50 widthScroll = outer.clientWidth;
51 }
52
53 document.body.removeChild(outer);
54
55 const width = widthContained - widthScroll;
56
57 _scrollBarSize = { width, height: width };
58 return _scrollBarSize;
59}
60
61export const uniqueId = (() => {
62 let id = 0;

Callers

nothing calls this directly

Calls 1

extendFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…