()
| 7 | let scrollBarWidth: ?number; |
| 8 | |
| 9 | export function getScrollBarWidth(): ?number { |
| 10 | if (scrollBarWidth !== undefined) return scrollBarWidth; |
| 11 | const dom = _document.createElement('div'); |
| 12 | const body = _document.body || dom; |
| 13 | |
| 14 | dom.style.visibility = 'hidden'; |
| 15 | dom.style.width = '100px'; |
| 16 | dom.style.position = 'absolute'; |
| 17 | dom.style.top = '-9999px'; |
| 18 | dom.style.overflow = 'scroll'; |
| 19 | |
| 20 | body.appendChild(dom); |
| 21 | |
| 22 | const totalWidth = dom.offsetWidth; |
| 23 | const widthWithoutScroll = dom.clientWidth; |
| 24 | |
| 25 | body.removeChild(dom); |
| 26 | |
| 27 | return totalWidth - widthWithoutScroll; |
| 28 | } |
| 29 | |
| 30 | export function getValueByPath(data: Object, path: ?string): any { |
| 31 | if (typeof path !== 'string') return null; |
no test coverage detected