mirror of
https://github.com/dillonzq/LoveIt.git
synced 2024-11-14 02:46:16 +01:00
Merge pull request #60 from Fedomn/develop
fix(toc): fix inaccurate headerLinkTop calculation
This commit is contained in:
commit
3ce7711608
1 changed files with 3 additions and 4 deletions
|
@ -175,13 +175,12 @@ jQuery(function($) {
|
|||
};
|
||||
changeTocState();
|
||||
|
||||
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) {
|
||||
|
@ -191,7 +190,7 @@ jQuery(function($) {
|
|||
return array.length - 1;
|
||||
};
|
||||
|
||||
const activeTocIndex = searchActiveTocIndex(headerlinkTop, scrollTop + HEADERFIX);
|
||||
const activeTocIndex = searchActiveTocIndex(headerlinkTop, scrollTop);
|
||||
|
||||
$($toclink).removeClass('active');
|
||||
$($tocLinkLis).removeClass('has-active');
|
||||
|
|
Loading…
Reference in a new issue