Prevent the anchor of the heading from being awakened early
This commit is contained in:
parent
259d0deabc
commit
09742d40dd
3 changed files with 7 additions and 23 deletions
|
@ -8,7 +8,6 @@
|
|||
*/
|
||||
|
||||
$(function() {
|
||||
const REM = 16; /* 16px */
|
||||
const $topbarTitle = $("#topbar-title");
|
||||
const topbarHeight = $("#topbar-wrapper").outerHeight();
|
||||
const SCROLL_MARK = "scroll-focus";
|
||||
|
@ -40,27 +39,15 @@ $(function() {
|
|||
let destOffset = $target.offset().top;
|
||||
|
||||
if (destOffset < curOffset) { // scroll up
|
||||
if (toFootnoteRef) {
|
||||
// Avoid the top-bar covering `fnref` when scrolling up
|
||||
// because `fnref` has no `%anchor`(see: module.scss) style.
|
||||
destOffset -= (topbarHeight + REM / 2);
|
||||
}
|
||||
|
||||
if (isAnchor && $topbarTitle.is(":hidden")) {
|
||||
destOffset += topbarHeight;
|
||||
}
|
||||
|
||||
} else { // scroll down
|
||||
if (!isAnchor && !toFootnote) { // the ToC item
|
||||
destOffset += topbarHeight;
|
||||
if (!isAnchor && !toFootnote && $topbarTitle.is(":hidden")) { // the ToC item
|
||||
destOffset -= topbarHeight;
|
||||
}
|
||||
}
|
||||
|
||||
$("html,body").animate({
|
||||
scrollTop: destOffset
|
||||
}, 800, () => {
|
||||
|
||||
// const $target = $($target);
|
||||
}, 800, () => {
|
||||
$target.focus();
|
||||
|
||||
/* clean up old scroll mark */
|
||||
|
|
|
@ -11,12 +11,9 @@
|
|||
}
|
||||
|
||||
%section {
|
||||
padding-top: 3.5rem;
|
||||
margin-top: -2.5rem;
|
||||
|
||||
#core-wrapper & {
|
||||
line-height: 1.2;
|
||||
margin-bottom: 1rem;
|
||||
margin-top: 2.5rem;
|
||||
margin-bottom: 2rem;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -24,7 +21,7 @@
|
|||
> a {
|
||||
font-size: 70%;
|
||||
visibility: hidden;
|
||||
margin-left: 0.25rem;
|
||||
margin-left: 0.5rem;
|
||||
border-bottom: none !important;
|
||||
opacity: 0;
|
||||
transition: opacity 0.25s ease-in, visibility 0s ease-in 0.25s;
|
||||
|
|
2
assets/js/dist/post.min.js
vendored
2
assets/js/dist/post.min.js
vendored
File diff suppressed because one or more lines are too long
Loading…
Reference in a new issue