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: Scrollytelling: the reading line sits at the true line from scroll 0, and See inside adds nothing to the scroll length

Claude59cb0529c892
diff --git a/animations/01-scroll-based/scrollytelling/index.html b/animations/01-scroll-based/scrollytelling/index.html
index d421bd54..f809e41f 100644
--- a/animations/01-scroll-based/scrollytelling/index.html
+++ b/animations/01-scroll-based/scrollytelling/index.html
@@ -46,12 +46,16 @@
.pic{display:contents}
.cap{padding:2px 6px;border-radius:999px;white-space:nowrap;background:rgba(11,11,13,.95);color:#f4f4f2;border:1px solid rgba(244,244,242,.3);font:600 12.5px/16px var(--hb-font)}
.stage[data-hb-mode="inside"],.stage[data-hb-mode="compare"]{overflow-anchor:none}
- .fx{position:sticky;top:0;height:0;z-index:3;pointer-events:none}
+ /* its place in the flow is below the chapters' top padding: the margins lift it to the top of the scroll and give the space back */
+ .fx{position:sticky;top:0;height:0;z-index:3;pointer-events:none;margin:calc(-1 * var(--fxo,0px)) 0 var(--fxo,0px)}
.fx-line{position:absolute;left:-14px;right:-28px;top:calc(42cqh - 1px);height:2px;background:#ffd166;box-shadow:0 0 0 1px #000}
.fx-cap{position:absolute;right:0;top:calc(42cqh + 5px)}
/* the chapters' box is as tall as their text, so the layer in it keeps sticking to the top of the box all the way down */
- .stage[data-hb-mode="inside"] .chapters{align-self:flex-start}
- .stage[data-hb-mode="inside"] .fx{display:block}
+ @media(min-width:601px){
+ .stage[data-hb-mode="inside"] .chapters{align-self:flex-start;padding-bottom:0}
+ }
+ .stage[data-hb-mode="inside"] .ch:last-child .bar{bottom:0}
+ .stage[data-hb-mode="inside"] .fx{display:flow-root}
.stage[data-hb-mode="inside"] .ch{position:relative}
.stage[data-hb-mode="inside"] .ch-eye,.stage[data-hb-mode="inside"] .ch-head{opacity:.6}
.stage[data-hb-mode="inside"] .ch-body{opacity:.4}
@@ -317,6 +321,7 @@
// The first bar starts where the reading line is at the top of the box, as the page's own count does
function remeasure(){
stage.style.setProperty('--b0',Math.max(0,stage.clientHeight*0.42-els[0].offsetTop)+'px');
+ stage.style.setProperty('--fxo',chs.offsetTop+parseFloat(getComputedStyle(chs).paddingTop)+'px');
blW=blTrk.clientWidth;
update();
}