One custom property, --i, and one delay expression. No library
and no per-element JavaScript: the order is set once in the markup and the browser does the rest.
The step is capped by arithmetic, so a thirty-item grid does not make the last tile wait a second
and a half.
@keyframes arrive{
from{ opacity:0; translate:0 12px }
to { opacity:1; translate:0 0 }
}
.list.go .item{
animation: arrive 250ms var(--m-ease-emph-decelerate) both;
animation-delay: calc(var(--i, 0) * var(--step));
}
/* --i in the markup, or from nth-child if the count is fixed */
<li style="--i:0"> <li style="--i:1"> <li style="--i:2">
/* the cap is the only arithmetic, and it belongs wherever the count is known */
--step: min(40ms, calc(400ms / var(--count)));
@media (prefers-reduced-motion:reduce){
:root{ --step:0ms }
.list.go .item{ animation:none; opacity:1; translate:none }
}From the button is the order worth
learning. --i is not the loop index: it is the tile’s rank by distance from
wherever the interaction started. That one change is what makes a grid feel like it opened from
the thing you pressed, rather than like a list that happens to be animating.