1
0
Fork 0
mirror of https://github.com/koalyptus/TableFilter.git synced 2024-05-16 21:36:41 +02:00
TableFilter/doc/script/inner-link.js
2015-08-02 18:27:59 +10:00

19 lines
499 B
JavaScript

// inner link(#foo) can not correctly scroll, because page has fixed header,
// so, I manually scroll.
(function(){
function adjust() {
window.scrollBy(0, -55);
var el = document.querySelector('.inner-link-active');
if (el) el.classList.remove('inner-link-active');
var el = document.querySelector(location.hash);
if (el) el.classList.add('inner-link-active');
}
window.addEventListener('hashchange', adjust);
if (location.hash) {
setTimeout(adjust, 0);
}
})();