Sha256: b2baba9e7df1b03d484d0154dc4aec34684c7867e975e7820871d4dc5790562a

Contents?: true

Size: 588 Bytes

Versions: 2

Compression:

Stored size: 588 Bytes

Contents

window.addEventListener("hashchange", () => {
    // wait for anchor scroll to settle where it thinks is correct
    // without timeout, autoscroll takes effect too early
    setTimeout(onHashChange, 1000);
});

// adjust anchor tags to view with a fixed topnav bar
function onHashChange() {
    // get height of navbar
    let menu = document.getElementById("menu");
    // dynamically get menu height
    let menuStyle = getComputedStyle(menu);
    let menuHeight = parseInt(menuStyle.height);
    let pad = menuHeight + 10;

    window.scrollTo(window.scrollX, window.scrollY - pad);
}

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
jekyll-theme-cadre-0.1.20 assets/js/adjustAnchorLink.js
jekyll-theme-cadre-0.1.19 assets/js/adjustAnchorLink.js