Content arrives as it enters the view. Where the browser has scroll-driven
animations this is pure CSS — no observer, no scroll listener, no frame loop — and the
animation’s progress is the element’s own position rather than a clock. Where it does
not, one IntersectionObserver does the same job, and it is the only JavaScript on the
page.
/* 1. the finished state is the DEFAULT. Nothing is hidden by default. */
.card{ /* just a card */ }
@keyframes reveal{
from{ opacity:0; translate:0 14px }
to { opacity:1; translate:0 0 }
}
/* 2. the animation exists only where the timeline exists */
@supports (animation-timeline: view()){
.card{
animation: reveal linear both;
animation-timeline: view();
animation-range: entry 8% entry 32%; /* entry only: no un-reveal */
}
}
/* 3. and it exists nowhere at all under reduced motion */
@media (prefers-reduced-motion:reduce){
@supports (animation-timeline: view()){
.card{ animation:none; opacity:1; translate:none }
}
}The ranges, in one line each.
entry is the element crossing the leading edge. cover is its whole
journey across the scrollport. exit is it leaving. contain is only
the span where it is fully visible, which is the one to use for something taller than the
scrollport. A reveal uses entry; a parallax uses cover.