Touch gestures make carousels feel native on mobile.
Swipe detection:
Track touchstart position
Calculate delta on touchmove
On touchend, determine if swipe threshold met
Animate to next/previous or snap back
Code pattern:
const handleTouchEnd = () => {
const delta = touchEnd - touchStart;
if (Math.abs(delta) > threshold) {
delta > 0 ? goToPrev() : goToNext();
} else {
snapBack();
}
};
Threshold: Typically - pixels or % of slide width.