Skip to content

Commit

Permalink
Add an offset of :target to reduce back-to-top overlap
Browse files Browse the repository at this point in the history
  • Loading branch information
pradyunsg committed Jan 30, 2024
1 parent 9450148 commit 57dc5f1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/furo/assets/scripts/furo.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ function setupScrollSpy() {
navClass: "scroll-current",
offset: () => {
let rem = parseFloat(getComputedStyle(document.documentElement).fontSize);
return header.getBoundingClientRect().height + 0.5 * rem + 1;
return header.getBoundingClientRect().height + 2.5 * rem + 1;
},
});
}
Expand Down
2 changes: 1 addition & 1 deletion src/furo/assets/styles/_scaffold.sass
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ article

// Add a scroll margin for the content
:target
scroll-margin-top: var(--header-height)
scroll-margin-top: calc(var(--header-height) + 2.5rem)

// Show back-to-top below the header
.back-to-top
Expand Down
6 changes: 3 additions & 3 deletions src/furo/assets/styles/content/_target.sass
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
:target
scroll-margin-top: 0.5rem
scroll-margin-top: 2.5rem

@media (max-width: $full-width - $sidebar-width)
:target
scroll-margin-top: calc(0.5rem + var(--header-height))
scroll-margin-top: calc(2.5rem + var(--header-height))

// When a heading is selected
section > span:target
scroll-margin-top: calc(0.8rem + var(--header-height))
scroll-margin-top: calc(2.8rem + var(--header-height))

// Permalinks
.headerlink
Expand Down

0 comments on commit 57dc5f1

Please sign in to comment.