From 82ce5b80d66ab1bb8ac40b408d9a35686c72ec9b Mon Sep 17 00:00:00 2001 From: spirit Date: Thu, 26 Sep 2019 18:26:37 +0800 Subject: [PATCH] fix #79 --- js/sakura-app.js | 17 ++++------------- style.css | 7 +++++++ 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/js/sakura-app.js b/js/sakura-app.js index 954660c..3889cd9 100644 --- a/js/sakura-app.js +++ b/js/sakura-app.js @@ -546,20 +546,10 @@ function tableOfContentScroll(flag) { } else if ($("div").hasClass("have-toc") == false && $("div").hasClass("has-toc") == false) { $(".toc-container").remove(); } else { - $(document).ready(function () { - if ($("div").hasClass("toc")) { - $(".toc-container").css("height", $(".site-content").outerHeight()); - setTimeout(function () { - $(".toc-container").css("height", $(".site-content").outerHeight()); - }, 1000); - setTimeout(function () { - $(".toc-container").css("height", $(".site-content").outerHeight()); - }, 6000); - } - }); if (flag) { - var id = 1; - $(".entry-content , .links").children("h1,h2,h3,h4,h5").each(function () { + var id = 1, + heading_fix=$("div").hasClass("pattern-attachment-img") ? -75 : 200; + $(".entry-content , .links").children("h1,h2,h3,h4,h5").each(function() { var hyphenated = "toc-head-" + id; this.id = hyphenated; id++; @@ -568,6 +558,7 @@ function tableOfContentScroll(flag) { tocSelector: '.toc', contentSelector: ['.entry-content', '.links'], headingSelector: 'h1, h2, h3, h4, h5', + headingsOffset: heading_fix-window.innerHeight/2, }); } } diff --git a/style.css b/style.css index fbebbee..d0af658 100644 --- a/style.css +++ b/style.css @@ -8480,4 +8480,11 @@ td.hljs-ln-numbers { background: #ddd; color: black; } +h1[id*=toc-head]::before,h2[id*=toc-head]::before,h3[id*=toc-head]::before,h4[id*=toc-head]::before,h5[id*=toc-head]::before,h6[id*=toc-head]::before { + display:block; + content:" "; + height:80px; + margin-top:-80px; + visibility:hidden +}