()
| 2 | let scrollbarWidth = false; |
| 3 | |
| 4 | export 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 | } |
no outgoing calls
no test coverage detected
searching dependent graphs…