diff options
author | Annabel Dunstone Gray <annabel.dunstone@gmail.com> | 2017-06-23 08:24:15 +0000 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-06-23 08:24:15 +0000 |
commit | 588d55646d21dbd47e439f9cb1f2b0743e88a257 (patch) | |
tree | 5ee116032ab98cc2660ac6b4a3ca41c3f16ca0c4 /app/assets/javascripts/lib/utils/common_utils.js | |
parent | 6106400662c2af2ecba905221b00b712411f24ae (diff) | |
download | gitlab-ce-588d55646d21dbd47e439f9cb1f2b0743e88a257.tar.gz |
Fix offset for fixed nav
Diffstat (limited to 'app/assets/javascripts/lib/utils/common_utils.js')
-rw-r--r-- | app/assets/javascripts/lib/utils/common_utils.js | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/app/assets/javascripts/lib/utils/common_utils.js b/app/assets/javascripts/lib/utils/common_utils.js index 2aca86189fd..122ec138c59 100644 --- a/app/assets/javascripts/lib/utils/common_utils.js +++ b/app/assets/javascripts/lib/utils/common_utils.js @@ -86,18 +86,25 @@ // This is required to handle non-unicode characters in hash hash = decodeURIComponent(hash); + var fixedTabs = document.querySelector('.js-tabs-affix'); + var fixedNav = document.querySelector('.navbar-gitlab'); + + var adjustment = 0; + if (fixedNav) adjustment -= fixedNav.offsetHeight; + // scroll to user-generated markdown anchor if we cannot find a match if (document.getElementById(hash) === null) { var target = document.getElementById('user-content-' + hash); if (target && target.scrollIntoView) { target.scrollIntoView(true); + window.scrollBy(0, adjustment); } } else { // only adjust for fixedTabs when not targeting user-generated content - var fixedTabs = document.querySelector('.js-tabs-affix'); if (fixedTabs) { - window.scrollBy(0, -fixedTabs.offsetHeight); + adjustment -= fixedTabs.offsetHeight; } + window.scrollBy(0, adjustment); } }; |