diff options
author | Sta7e <Sta7e@users.noreply.github.com> | 2021-03-19 05:29:59 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-03-19 05:29:59 +0300 |
commit | 12321ef6918c2f5b0567756b9026594308c7fd0f (patch) | |
tree | 5716aad1106678d82d88fb983ed1f1e2cc9abfd5 | |
parent | 4d6f8a51e53b531e7169ea4162e19972da3de480 (diff) |
activate last section heading when approaching footer (#21)
-rw-r--r-- | static/js/index.js | 38 |
1 files changed, 22 insertions, 16 deletions
diff --git a/static/js/index.js b/static/js/index.js index 2558e3b..fe53c5d 100644 --- a/static/js/index.js +++ b/static/js/index.js @@ -81,24 +81,30 @@ var $sitehead = $("#site-head"); } $post.each(function () { - var f = $(this).offset().top; - var b = $(this).offset().top + $(this).height(); - var t = $(this).parent(".post-holder").index(); - var i = $(".fn-item[item_index='" + t + "']"); - var a = $(this) - .parent(".post-holder") - .prev(".post-holder") - .find(".post-after"); + if (($(window).height() + w) > ($(document).height() - $(".site-footer").height())) { + var l = $postholder.length; + $(".fn-item[item_index='" + (l - 1) + "']").removeClass("active") + $(".fn-item[item_index='" + (l) + "']").addClass("active") + } else { + var f = $(this).offset().top; + var b = $(this).offset().top + $(this).height(); + var t = $(this).parent(".post-holder").index(); + var i = $(".fn-item[item_index='" + t + "']"); + var a = $(this) + .parent(".post-holder") + .prev(".post-holder") + .find(".post-after"); - $(this).attr("item_index", t); + $(this).attr("item_index", t); - if (w >= f && w <= b) { - i.addClass("active"); - a.fadeOut("slow"); - } else { - i.removeClass("active"); - a.fadeIn("slow"); - } + if (w >= f && w <= b) { + i.addClass("active"); + a.fadeOut("slow"); + } else { + i.removeClass("active"); + a.fadeIn("slow"); + } + } }); }); } |