From 440051ec80adc561e6779876bdd21be63713a54d Mon Sep 17 00:00:00 2001 From: Fedomn Date: Sun, 9 Feb 2020 10:27:30 +0800 Subject: [PATCH] fix(toc): fix inaccurate headerLinkTop calculation that result in activeTocIndex drift. --- assets/js/blog.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/assets/js/blog.js b/assets/js/blog.js index 81b81d0d..35d91398 100644 --- a/assets/js/blog.js +++ b/assets/js/blog.js @@ -160,11 +160,11 @@ jQuery(function($) { const HEADERFIX = 120; const $toclink = $('.toc-link'); - const $headerlink = $('.headerlink'); + const $headerDummyLink = $('.post-dummy-target'); const $tocLinkLis = $('.post-toc-content li'); const activeIndex = function () { const scrollTop = $(window).scrollTop(); - const headerlinkTop = $.map($headerlink, function(link) { + const headerlinkTop = $.map($headerDummyLink, function(link) { return $(link).offset().top; }); const searchActiveTocIndex = function(array, target) {