UNPKG

@scalar/themes

Version:

the default CSS variables for all Scalar packages

20 lines (19 loc) 631 B
function hasObtrusiveScrollbars() { if (typeof window === "undefined") { return false; } const parent = document.createElement("div"); parent.setAttribute("style", "width:30px;height:30px;overflow-y:scroll;"); parent.classList.add("scrollbar-test"); const child = document.createElement("div"); child.setAttribute("style", "width:100%;height:40px"); parent.appendChild(child); document.body.appendChild(parent); const firstChild = parent.firstChild; const scrollbarWidth = 30 - firstChild.clientWidth; document.body.removeChild(parent); return !!scrollbarWidth; } export { hasObtrusiveScrollbars };