UNPKG

@lani.ground/react-modal

Version:
26 lines (25 loc) 1.06 kB
var isBrowser = typeof window !== 'undefined'; export var isMobileDevice = function () { if (!isBrowser || !navigator) return false; return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent); }; export var getScrollbarWidth = function () { var _a; if (!isBrowser || !(document === null || document === void 0 ? void 0 : document.body)) return 0; var outer = document.createElement('div'); outer.style.visibility = 'hidden'; outer.style.overflow = 'scroll'; document.body.appendChild(outer); var inner = document.createElement('div'); outer.appendChild(inner); var scrollbarWidth = outer.offsetWidth - inner.offsetWidth; (_a = outer.parentNode) === null || _a === void 0 ? void 0 : _a.removeChild(outer); return scrollbarWidth; }; export var hasBodyScroll = function () { if (!isBrowser || !(document === null || document === void 0 ? void 0 : document.body)) return false; return document.body.scrollHeight > window.innerHeight; };