Sign in

Search issue titles and bodies, change requests and comments. Private repositories you cannot read are not included.

vole
Site
Clone

Read only, no credentials:

https://rodent.software/vole.git

Write over SSH with a registered key:

git clone ssh://git@rodent.software/vole.git

Self-hosted forge that lives in your Git repo.

Keep the docs shell still while the article scrolls

a01724266be31c99cf2bb9f63d1a324ddf6ff6fa · Keenan Nemetz · 20d ago · parent 59edfa98

Keep the docs shell still while the article scrolls

The top bar was position: sticky and translucent, so the page kept drawing
through it as it scrolled: the bar looked like it moved even when its box did
not, and in Firefox the blurred backdrop of a fixed bar is the least reliable
compositing path there is.

Body is now one viewport tall with overflow: hidden, the bar is position: fixed
and opaque, and .content, .sidebar, and .toc each scroll inside their own
column. Nothing is drawn under the bar because the document never scrolls. The
footer moves inside the article column, fragment jumps take their offset from
the pane's scroll-padding-top, and a print block undoes the shell so a long
article still prints whole.

docs-theme/assets/docs.css +70−22

@@ -122,12 +122,19 @@
122 122 ::-webkit-scrollbar-track { background: transparent; }
123 123
124 124 html {
125 scroll-behavior: smooth;
126 scroll-padding-top: calc(var(--topbar-h) + 24px);
125 /* The shell owns the viewport: the bar, the pages' side columns, and the
126 article pane scroll on their own. A fragment jump widens the article pane,
127 so its scroll-padding keeps the heading clear of the bar. */
128 height: 100%;
127 129 }
128 130
129 131 body {
130 132 margin: 0;
133 /* Reserve the fixed bar's height, then never let the document scroll: the
134 shell below is exactly one viewport tall. */
135 padding-top: var(--topbar-h);
136 height: 100dvh;
137 overflow: hidden;
131 138 background: var(--bg);
132 139 color: var(--fg);
133 140 font-family: var(--font);
@@ -188,8 +195,12 @@ kbd {
188 195 /* ---------- top bar ---------- */
189 196
190 197 .topbar {
191 position: sticky;
198 /* Fixed rather than sticky: the bar never moves, whatever the page does
199 inside it, and it does not depend on no ancestor scrolling. */
200 position: fixed;
192 201 top: 0;
202 left: 0;
203 right: 0;
193 204 z-index: 20;
194 205 display: flex;
195 206 align-items: center;
@@ -197,9 +208,12 @@ kbd {
197 208 height: var(--topbar-h);
198 209 padding-block: 0;
199 210 padding-inline: max(var(--page-gutter), calc((100% - var(--layout-max)) / 2 + var(--page-gutter)));
200 background: color-mix(in srgb, var(--bg-panel) 92%, transparent);
211 /* Opaque, and no backdrop-filter. A translucent fixed bar lets the page show
212 through as it scrolls underneath, and Firefox composites blurred backdrops
213 on fixed elements badly enough that the bar reads as moving. The bar keeps
214 its place, and the page stops leaking into it. */
215 background: var(--bg-panel);
201 216 border-bottom: 1px solid var(--border);
202 backdrop-filter: blur(8px);
203 217 }
204 218
205 219 .brand {
@@ -340,21 +354,23 @@ kbd {
340 354 display: grid;
341 355 grid-template-columns: var(--sidebar-w) minmax(0, var(--content-max)) var(--toc-w);
342 356 justify-content: center;
343 align-items: start;
357 /* Full height, and every column scrolls itself. The bar and the columns keep
358 their place because nobody ever scrolls the document. */
359 align-items: stretch;
344 360 gap: var(--layout-gap);
345 361 width: min(100%, var(--layout-max));
362 height: calc(100dvh - var(--topbar-h));
346 363 margin: 0 auto;
347 padding: 28px var(--page-gutter) 80px;
364 padding: 0 var(--page-gutter);
365 overflow: hidden;
348 366 }
349 367
350 368 /* ---------- sidebar ---------- */
351 369
352 370 .sidebar {
353 position: sticky;
354 top: calc(var(--topbar-h) + 24px);
355 max-height: calc(100vh - var(--topbar-h) - 48px);
356 371 overflow-y: auto;
357 padding-right: 4px;
372 overscroll-behavior: contain;
373 padding: 28px 4px 40px 0;
358 374 }
359 375
360 376 .nav-list { list-style: none; margin: 0; padding: 0; }
@@ -395,6 +411,11 @@ kbd {
395 411 .content {
396 412 min-width: 0;
397 413 max-width: var(--content-max);
414 overflow-y: auto;
415 overscroll-behavior: contain;
416 padding-block: 28px 0;
417 scroll-padding-top: 24px;
418 scroll-behavior: smooth;
398 419 }
399 420
400 421 .content > :first-child { margin-top: 0; }
@@ -572,9 +593,10 @@ h6:hover .headerlink,
572 593 .pager-next .pager-title { color: var(--accent); }
573 594
574 595 .site-footer {
575 width: min(100%, var(--layout-max));
576 margin: 0 auto;
577 padding: 18px var(--page-gutter) 40px;
596 /* Inside the article pane now, so it scrolls with the text instead of
597 sitting in a band of its own below the shell. */
598 margin: 56px 0 0;
599 padding: 18px 0 48px;
578 600 border-top: 1px solid var(--border);
579 601 color: var(--fg-faint);
580 602 font-size: calc(12.65px * 1);
@@ -587,10 +609,9 @@ h6:hover .headerlink,
587 609 /* ---------- on this page ---------- */
588 610
589 611 .toc {
590 position: sticky;
591 top: calc(var(--topbar-h) + 24px);
592 max-height: calc(100vh - var(--topbar-h) - 48px);
593 612 overflow-y: auto;
613 overscroll-behavior: contain;
614 padding-block: 28px 40px;
594 615 font-size: calc(12.65px * 1);
595 616 }
596 617 .toc-title {
@@ -744,9 +765,13 @@ h6:hover .headerlink,
744 765
745 766 .layout {
746 767 display: block;
747 padding-top: 20px;
768 padding-top: 0;
769 }
770 .content {
771 height: 100%;
772 max-width: var(--content-max);
773 padding-block: 20px 0;
748 774 }
749 .content { max-width: var(--content-max); }
750 775
751 776 .sidebar {
752 777 position: fixed;
@@ -755,7 +780,6 @@ h6:hover .headerlink,
755 780 left: 0;
756 781 z-index: 30;
757 782 width: min(20rem, 85vw);
758 max-height: none;
759 783 padding: 16px 14px 32px;
760 784 background: var(--bg-panel);
761 785 border-right: 1px solid var(--border);
@@ -786,14 +810,38 @@ h6:hover .headerlink,
786 810 .topbar-link .icon { display: none; }
787 811 .topbar-link { padding-inline: 2px; }
788 812 .layout { padding-inline: 16px; }
789 .site-footer { padding-inline: 16px; }
790 813 .content h1 { font-size: calc(20.9px * 1); }
791 814 .pager { grid-template-columns: 1fr; }
792 815 .palette-foot { display: none; }
793 816 }
794 817
818 /* The shell assumes a viewport. On paper there is none: undo the panes so a
819 long article prints whole instead of clipping to the visible scroll window. */
820 @media print {
821 html, body { height: auto; }
822 body { padding-top: 0; overflow: visible; }
823 .topbar,
824 .sidebar,
825 .toc,
826 .pager,
827 .nav-scrim { display: none; }
828 .layout {
829 display: block;
830 height: auto;
831 padding: 0;
832 overflow: visible;
833 }
834 .content {
835 height: auto;
836 max-width: none;
837 padding: 0;
838 overflow: visible;
839 scroll-behavior: auto;
840 }
841 }
842
795 843 @media (prefers-reduced-motion: reduce) {
796 html { scroll-behavior: auto; }
844 .content { scroll-behavior: auto; }
797 845 *,
798 846 *::before,
799 847 *::after { animation-duration: 0.01ms !important; transition-duration: 0.01ms !important; }