Experimental
Scroll Trigger
Use CSS animation-trigger to animate slides based on their scroll state.
.carousel {
display: grid;
grid-auto-flow: column;
grid-auto-columns: 200px;
gap: 1rem;
scroll-snap-type: x mandatory;
}
.slide {
width: 100%;
aspect-ratio: 3 / 4;
scroll-snap-align: center;
timeline-trigger-name: --t;
timeline-trigger-source: view(inline);
animation: unclip 0.35s ease-in-out both;
animation-trigger: --t play-forwards play-backwards;
}
@keyframes unclip {
from {
clip-path: inset(100% 0 0 0 round 1rem);
}
to {
clip-path: inset(0);
}
}
<BlossomCarousel class="carousel">
<div class="slide"></div>
<div class="slide"></div>
<div class="slide"></div>
...
</BlossomCarousel>
.slide {
timeline-trigger-name: --t;
timeline-trigger-source: view(inline);
animation: unclip 0.35s ease-in-out both;
animation-trigger: --t play-forwards play-backwards;
}
@keyframes unclip {
from {
clip-path: inset(100% 0 0 0 round 1rem);
}
to {
clip-path: inset(0);
}
}
<BlossomCarousel
class="grid! auto-cols-[200px] snap-x snap-mandatory grid-flow-col gap-4"
>
<div class="slide w-full snap-center aspect-3/4"></div>
<div class="slide w-full snap-center aspect-3/4"></div>
<div class="slide w-full snap-center aspect-3/4"></div>
...
</BlossomCarousel>