Javascript to shift window for in-page anchors.
In my research about issues with in-page anchors, I found this code that might be useful. More details once I've adapted it.
This commit is contained in:
parent
04b105a147
commit
fd1d257184
1 changed files with 20 additions and 0 deletions
|
@ -25,3 +25,23 @@ $( ".footnote-mark" ).tooltip({
|
|||
}
|
||||
}});
|
||||
});
|
||||
// The following code was borrowed from:
|
||||
// https://github.com/pierre-rouanet/sphinxjp.themes.basicstrap/commit/05ac6055be8cbb6097f16ab106df5244c19a067f
|
||||
// which was licensed under the MIT license.
|
||||
|
||||
$(window).load(function () {
|
||||
/*
|
||||
* Scroll the window to avoid the topnav bar
|
||||
* https://github.com/twitter/bootstrap/issues/1768
|
||||
*/
|
||||
if ($(".navbar.navbar-fixed-top").length > 0) {
|
||||
// var navHeight = $(".navbar").height(),
|
||||
var navHeight = 40,
|
||||
shiftWindow = function() { scrollBy(0, -navHeight - 10); };
|
||||
|
||||
if (location.hash) {
|
||||
setTimeout(shiftWindow, 1);
|
||||
}
|
||||
window.addEventListener("hashchange", shiftWindow);
|
||||
}
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue