Repository navigation
Conversation
The fixed navbar hid after about 5 px of scroll, while the body kept a top padding as tall as the header. An empty band then showed at the top of the page until it scrolled past that padding. Headroom now gets the header height as its offset, and the offset follows the header height when it changes.
Collaborator
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On a website with a fixed navbar, the header hides as soon as the page scrolls about 5 px.
The body keeps a top padding as tall as the header, so an empty band shows at the top of the page until the scroll passes that padding.
A taller header makes the band bigger, for example with a secondary navigation row.
Headroom is created without an
offset, so it unpins the header right away.This passes the header height as the
offset, andupdateDocumentOffset()keeps it in step when the header height changes, from the sameResizeObserverthat already updates the body padding.The header now stays in place until the page has scrolled past its height, then hides as before.
Scrolling up still brings it back.
The new Playwright test checks that the header stays pinned at half its height, hides further down, and comes back on scroll up.
Both clips use a website with a fixed navbar and a docked sidebar.
The sidebar has a border only to make the layout easier to see.
They scroll slowly from the top, then further down the page, back up a little, and down again.
Before, with stock Quarto, the header hides at once: the sidebar moves up to the top of the window, but the page content keeps an empty band above the title.
Further down, it hides and comes back as usual.
navbar-scroll-before.mp4
After this change, the header and the sidebar stay in place until the scroll passes the 61 px header height, then the header hides with no gap.
Further down, it hides on scroll down and comes back on scroll up, as before.
navbar-scroll-after.mp4
Checklist
I have (if applicable):