Skip to content

176 web animation techniques, each a live demo with plain settings and a ready-made prompt for your AI assistant. No dependencies, no build step.

fix: Hide-on-Scroll Header README on the bar's offset and scroll direction in CSS

matin9b4f73257bd1
diff --git a/animations/01-scroll-based/hide-on-scroll-header/README.md b/animations/01-scroll-based/hide-on-scroll-header/README.md
index 2b890224..fe0c921d 100644
--- a/animations/01-scroll-based/hide-on-scroll-header/README.md
+++ b/animations/01-scroll-based/hide-on-scroll-header/README.md
@@ -35,7 +35,7 @@ scroller.addEventListener('scroll', () => {
```css
.topbar { position: absolute; top: 0; left: 0; right: 0; transition: transform var(--dur) var(--ease); }
-.topbar.away { transform: translateY(calc(-100% - 2px)); } /* its height and its border */
+.topbar.away { transform: translateY(calc(-100% - 2px)); } /* its full height, border included, and 2px to spare */
.shrink .topbar.away { transform: translateY(-18px); } /* a slim strip stays */
.shrink .topbar.away .brand { transform: translateY(9px) scale(.82); } /* centered in the strip */
@@ -64,7 +64,7 @@ Show me scrolls the box itself, one and a half boxes down and back, with each fr
- **Transform only**: never animate `top`, `margin` or `height`. Moving the bar with a transform keeps it on the compositor, and the shrinking version scales the contents instead of changing font sizes.
- **Reduced motion**: fade the bar out and in, or leave it in place, instead of sliding it.
- **Do not hide key actions**: a bar that holds the main button of the page (checkout, compose, save) should stay.
-- **Libraries**: Headroom.js does exactly this, with options for the threshold and the offset from the top; in React or Vue a small scroll-direction hook does the same. CSS scroll-driven animations cannot read the scroll direction yet, so the direction check stays in JavaScript.
+- **Libraries**: Headroom.js does exactly this, with options for the threshold and the offset from the top; in React or Vue a small scroll-direction hook does the same. Newer versions of Chromium add scroll-state container queries that can tell which way a box last scrolled, aimed at exactly this, but CSS alone cannot do it in every browser yet, so the direction check stays in JavaScript here.
## See also
diff --git a/animations/01-scroll-based/hide-on-scroll-header/index.html b/animations/01-scroll-based/hide-on-scroll-header/index.html
index 1426daea..04e29766 100644
--- a/animations/01-scroll-based/hide-on-scroll-header/index.html
+++ b/animations/01-scroll-based/hide-on-scroll-header/index.html
@@ -34,7 +34,7 @@
.nav{gap:clamp(14px,2.4vw,24px);transform-origin:right center;font-size:14px;color:#adadb2}
.menu{display:none;flex-direction:column;align-items:stretch;justify-content:center;gap:4px;width:20px;transform-origin:right center}
.menu i{display:block;height:2px;border-radius:1px;background:#d6d6da}
- /* Scrolled down: the bar slides up by its own height, border included, out of view */
+ /* Scrolled down: the bar slides up by its own height (border included) and 2px to spare, out of view */
.topbar.away{transform:translateY(calc(-100% - 2px))}
/* Shrinks instead: a slim strip stays, its contents smaller and centered in what is left of it */
.stage.shrink .topbar.away{transform:translateY(-18px)}