/** * Maps a horizontal swipe delta to a cycle direction. A leftward swipe (negative * dx) advances to the next pairing (+1); a rightward swipe (positive dx) goes to * the previous (-1). Movement below the threshold is ignored (0). * * @param dx - Horizontal travel in px (end minus start). * @param threshold - Minimum absolute travel in px to count as a swipe. * @returns +1 (next), -1 (previous), or 0 (no cycle). */ export function swipeDirection(dx: number, threshold: number): -1 | 0 | 1 { if (dx <= -threshold) { return 1; } if (dx >= threshold) { return -1; } return 0; }