GSAP Carousel
A dependency-light carousel built with GSAP core only — no slider library. Draggable with flick momentum, snap-to-slide, seamless infinite loop, dot pagination, active-slide animation, keyboard accessible, and respectful of reduced-motion preferences.
Specification
- ID
- STDR_001
- Status
- Developing — API may change until v1.0.0
- Stack
- GSAP (core only) · Vanilla JS · React port
- Dependencies
- gsap ^3.12
- Licence
- MIT
- CodePen
- Fork on CodePen ↗
Quick start
<link rel="stylesheet" href="stdr-carousel.css">
<div class="stdr-carousel" data-stdr>
<div class="stdr-track" data-stdr-track>
<div class="stdr-slide">…</div>
<div class="stdr-slide">…</div>
</div>
<button data-stdr-prev>←</button>
<button data-stdr-next>→</button>
<div class="stdr-pagination" data-stdr-pagination></div>
<span data-stdr-count></span>
</div>
<script src="gsap.min.js"></script>
<script src="stdr-carousel.js"></script>
<script>
new STDRCarousel('[data-stdr]', {
drag: true,
keyboard: true,
loop: true, // seamless infinite loop
pagination: true, // dots, rendered into [data-stdr-pagination]
activeAnimation: true // tween active / dimmed slide states
});
</script>
Notes
Canonical version is vanilla JS; the React port mirrors its behaviour and reuses the same stylesheet. Slide sizing is fully controlled by your CSS. All extras default to off — loop clones slides at the track boundaries but stdr:change always reports the real slide index; pagination dots take the shortest path when looping. Full API in the repo README.