diff --git a/app/ui.js b/app/ui.js index c1f6776e..c8cc4e29 100644 --- a/app/ui.js +++ b/app/ui.js @@ -1335,7 +1335,7 @@ const UI = { let brokenScrollbars = false; - if (!hasScrollbarGutter) { + if (!hasScrollbarGutter()) { if (isIOS() || isAndroid() || isMac() || isChromeOS()) { brokenScrollbars = true; } diff --git a/core/util/browser.js b/core/util/browser.js index bbc9f5c1..932d7484 100644 --- a/core/util/browser.js +++ b/core/util/browser.js @@ -45,30 +45,32 @@ try { export const supportsCursorURIs = _supportsCursorURIs; -let _hasScrollbarGutter = true; -try { - // Create invisible container - const container = document.createElement('div'); - container.style.visibility = 'hidden'; - container.style.overflow = 'scroll'; // forcing scrollbars - document.body.appendChild(container); +export const hasScrollbarGutter = () => { + let _hasScrollbarGutter = true; + try { + // Create invisible container + const container = document.createElement('div'); + container.style.visibility = 'hidden'; + container.style.overflow = 'scroll'; // forcing scrollbars + document.body.appendChild(container); - // Create a div and place it in the container - const child = document.createElement('div'); - container.appendChild(child); + // Create a div and place it in the container + const child = document.createElement('div'); + container.appendChild(child); - // Calculate the difference between the container's full width - // and the child's width - the difference is the scrollbars - const scrollbarWidth = (container.offsetWidth - child.offsetWidth); + // Calculate the difference between the container's full width + // and the child's width - the difference is the scrollbars + const scrollbarWidth = (container.offsetWidth - child.offsetWidth); - // Clean up - container.parentNode.removeChild(container); + // Clean up + container.parentNode.removeChild(container); - _hasScrollbarGutter = scrollbarWidth != 0; -} catch (exc) { - Log.Error("Scrollbar test exception: " + exc); -} -export const hasScrollbarGutter = _hasScrollbarGutter; + _hasScrollbarGutter = scrollbarWidth != 0; + } catch (exc) { + Log.Error("Scrollbar test exception: " + exc); + } + return _hasScrollbarGutter; +}; /* * The functions for detection of platforms and browsers below are exported