docs: hide permalinks unless hovered, fix scroll to hash

This commit is contained in:
jean-emmanuel 2019-04-08 12:55:11 +02:00
parent 6ebd411368
commit 4e6d11b49b
2 changed files with 20 additions and 4 deletions

View file

@ -229,11 +229,14 @@ table .thead2 {
.headerlink {
// font-size:50%;
opacity: 0.5;
opacity: 0;
position: relative;
margin-left: 4px;
}
:hover > .headerlink {
opacity: 0.5;
}
h1:first-child {
margin-top:0;

View file

@ -1,8 +1,21 @@
var offset = 80
function getOffset(element) {
var offset = 0
if (element) {
do {
if (!isNaN(element.offsetTop)) {
offset += element.offsetTop - element.scrollTop
}
} while ((element = element.offsetParent))
}
return offset
}
var navHeight = 80
function offsetScroll(){
if (document.location.hash) {
var el = document.getElementById(document.location.hash.substring(1))
if (el) document.body.scrollTop = document.documentElement.scrollTop = el.offsetTop - offset
if (el) document.body.scrollTop = document.documentElement.scrollTop = getOffset(el) - navHeight
}
}
window.addEventListener('hashchange', offsetScroll)