diff options
Diffstat (limited to 'app/assets/javascripts/lib/utils/common_utils.js')
-rw-r--r-- | app/assets/javascripts/lib/utils/common_utils.js | 23 |
1 files changed, 21 insertions, 2 deletions
diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js index 30925940807..e14fff7a610 100644 --- a/app/assets/javascripts/lib/utils/common_utils.js +++ b/app/assets/javascripts/lib/utils/common_utils.js @@ -88,6 +88,7 @@ export const handleLocationHash = () => { const fixedDiffStats = document.querySelector('.js-diff-files-changed'); const fixedNav = document.querySelector('.navbar-gitlab'); const performanceBar = document.querySelector('#js-peek'); + const topPadding = 8; let adjustment = 0; if (fixedNav) adjustment -= fixedNav.offsetHeight; @@ -108,6 +109,10 @@ export const handleLocationHash = () => { adjustment -= performanceBar.offsetHeight; } + if (isInMRPage()) { + adjustment -= topPadding; + } + window.scrollBy(0, adjustment); }; @@ -381,8 +386,11 @@ export const objectToQueryString = (params = {}) => .map(param => `${param}=${params[param]}`) .join('&'); -export const buildUrlWithCurrentLocation = param => - (param ? `${window.location.pathname}${param}` : window.location.pathname); +export const buildUrlWithCurrentLocation = param => { + if (param) return `${window.location.pathname}${param}`; + + return window.location.pathname; +}; /** * Based on the current location and the string parameters provided @@ -616,6 +624,17 @@ export const roundOffFloat = (number, precision = 0) => { return Math.round(number * multiplier) / multiplier; }; +/** + * Represents navigation type constants of the Performance Navigation API. + * Detailed explanation see https://developer.mozilla.org/en-US/docs/Web/API/PerformanceNavigation. + */ +export const NavigationType = { + TYPE_NAVIGATE: 0, + TYPE_RELOAD: 1, + TYPE_BACK_FORWARD: 2, + TYPE_RESERVED: 255, +}; + window.gl = window.gl || {}; window.gl.utils = { ...(window.gl.utils || {}), |