On scroll
An in animation normally plays the moment its component mounts. With trigger: 'visible' it waits until the element scrolls into view, holding at its from keyframe until then, and plays once.
in: {
from: { opacity: 0, transform: 'translateY(16px)' },
to: { opacity: 1, transform: 'translateY(0)' },
duration: 420,
easing: 'ease-out',
delay: Math.min(this.props.index ?? 0, 7) * 60,
trigger: 'visible',
triggerAnchor: '.grid',
triggerOffset: '10%',
},
triggerOffsetmoves the trigger line up from the bottom of the viewport, so a card plays once it is a little way in.triggerAnchorwatches an ancestor instead of the element itself. Every card in one.gridreveals in the same frame, and their delays turn that into a cascade.delaygrows with the card's place in its row: 0, 60, 120 milliseconds, capped so a long list never keeps anyone waiting.
The delay reads a prop, so write animations as a getter: get animations() { return { in: { … } }; }. Puzzle reads it when the card mounts, after its props have arrived.
Your turn
- In
Shop.pzl, give each loop an index ({#for album in albums, i}) and pass it on:<AlbumCard album={ album } index={ i } …/>. Do the same in both shelves. - In
AlbumCard.pzl, add the getter above. - Reload, then scroll the preview down to the shelves. Each one cascades in as it arrives.
With reduced motion there is no hold at all: every card simply shows.