diff --git a/src/utils/getScrollbarWidth.js b/src/utils/getScrollbarWidth.js index a8ee721..c13df6b 100644 --- a/src/utils/getScrollbarWidth.js +++ b/src/utils/getScrollbarWidth.js @@ -15,7 +15,13 @@ export default function getScrollbarWidth(cacheEnabled = true) { MsOverflowStyle: 'scrollbar' }); document.body.appendChild(div); - scrollbarWidth = (div.offsetWidth - div.clientWidth); + + if (div.offsetWidth !== 0 && div.clientWidth !== 0) { + scrollbarWidth = (div.offsetWidth - div.clientWidth); + } else { + scrollbarWidth = false; + } + document.body.removeChild(div); } else { scrollbarWidth = 0;