Sha256: cd6dd99fa7e262e48566e36fe327fe34302d17ee8b9c88eff9a1c98fc23d432a

Contents?: true

Size: 664 Bytes

Versions: 2

Compression:

Stored size: 664 Bytes

Contents

// When reading a post, update the on scroll 
$(window).scroll(function () {
    var position = $(this).scrollTop();
    var $sections = $(":header");
    var navbarHeight = getNavbarHeight();

    $sections.each(function () {
        var target = $(this).offset().top - navbarHeight;
        var id = $(this).attr('id');

        if (position >= target) {
            $('a').removeClass('active');
            $('a[href="#' + id + '"]').addClass('active');
        }
    });
});

getNavbarHeight = () => {
    let menu = document.getElementById("menu");
    let menuStyle = getComputedStyle(menu);
    let pad = 50;
    return (parseInt(menuStyle.height) + pad)
}

Version data entries

2 entries across 2 versions & 1 rubygems

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