The navbar that's eager to show up and be sticky when you need it (scroll up) but apart from that acts naturally. Maybe I should call it something like half-sticky or sticky-up? Eager ain't bad either.
The gist of it: I wanted a script to give my top navbar this behavior:
- When the navbar is visible (at the top of the document), as the document is scrolled down, the navbar follows until it finally gets out of view: in other words, no special behavior.
- But whenever the document is scrolled up, the navbar immediately starts getting back into view as if its bottom was positioned just above the top of the viewport. Noteworthy: it does so by following the scroll exactly, which means that it can remain partially visible if the amount of scrolling up is not sufficient to show it completely. (No fancy animation to bring the element into view!)
CSS-wise, it is assumed that the navbar element is at the top of the layout and that it either is not positioned or has `position: relative;