feat(Board): add keyboard and swipe focal cycling

This commit is contained in:
Ilia Mashkov
2026-06-24 15:31:38 +03:00
parent 118c588859
commit f3a2a6a7bd
3 changed files with 101 additions and 0 deletions
@@ -0,0 +1,18 @@
/**
* 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;
}