max / makenotwork
| 1 | // Pure carousel logic (no DOM) — imported by both the element and its test. |
| 2 | |
| 3 | /** |
| 4 | * Wrap `next` into `[0, len)`. Negative values wrap from the end (advancing |
| 5 | * "previous" past the first frame lands on the last), matching the original |
| 6 | * `(next + len) % len` but correct for any negative magnitude. |
| 7 | */ |
| 8 | export function wrapIndex(next: number, len: number): number { |
| 9 | return ((next % len) + len) % len; |
| 10 | } |
| 11 |