Account for merge request fixed affix bar
account for merge request fixed affix bar when adjusting scroll targets
This commit is contained in:
parent
0c99e5d0b6
commit
f02f08f53c
2 changed files with 19 additions and 2 deletions
|
@ -58,11 +58,28 @@
|
|||
document.addEventListener('page:fetch', gl.utils.cleanupBeforeFetch);
|
||||
window.addEventListener('hashchange', gl.utils.shiftWindow);
|
||||
|
||||
// automatically adjust scroll position for hash urls taking the height of the navbar into account
|
||||
// https://github.com/twitter/bootstrap/issues/1768
|
||||
window.adjustScroll = function() {
|
||||
var navbar = document.querySelector('.navbar-gitlab');
|
||||
var subnav = document.querySelector('.layout-nav');
|
||||
var fixedTabs = document.querySelector('.js-tabs-affix');
|
||||
|
||||
adjustment = 0;
|
||||
if (navbar) adjustment -= navbar.offsetHeight;
|
||||
if (subnav) adjustment -= subnav.offsetHeight;
|
||||
if (fixedTabs) adjustment -= fixedTabs.offsetHeight;
|
||||
|
||||
return scrollBy(0, adjustment);
|
||||
};
|
||||
|
||||
window.addEventListener("hashchange", adjustScroll);
|
||||
|
||||
window.onload = function () {
|
||||
// Scroll the window to avoid the topnav bar
|
||||
// https://github.com/twitter/bootstrap/issues/1768
|
||||
if (location.hash) {
|
||||
return setTimeout(gl.utils.shiftWindow, 100);
|
||||
return setTimeout(adjustScroll, 100);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -130,7 +130,7 @@
|
|||
MergeRequestTabs.prototype.scrollToElement = function(container) {
|
||||
var $el, navBarHeight;
|
||||
if (window.location.hash) {
|
||||
navBarHeight = $('.navbar-gitlab').outerHeight() + $('.layout-nav').outerHeight();
|
||||
navBarHeight = $('.navbar-gitlab').outerHeight() + $('.layout-nav').outerHeight() + document.querySelector('.js-tabs-affix').offsetHeight;
|
||||
$el = $(container + " " + window.location.hash + ":not(.match)");
|
||||
if ($el.length) {
|
||||
return $.scrollTo(container + " " + window.location.hash + ":not(.match)", {
|
||||
|
|
Loading…
Reference in a new issue