Files
AndreaSlopFotografie/web/src/lib/wrapIndex.ts
T
SluijsensandClaude Opus 5.5 18bf0311ef Adds the shared gallery building blocks
A masonry photo grid that keeps the reading order (pure CSS, no measuring
in the browser), an accessible lightbox on Chakra's Dialog with wrap-around
browsing, keys, swipe and preloading, and a filter bar of toggle buttons.
They work on generic gallery items, so other pages can use them. The swipe
logic moves out of the hero into a shared hook; the hero behaves as before.
The rules behind them live in pure helpers with property-based tests.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-25 23:22:43 +01:00

7 lines
311 B
TypeScript

// A position in a list of `count` items that wraps around both ways: one
// past the last is the first, one before the first is the last. Used for
// browsing photos in the hero and the lightbox.
export function wrapIndex(index: number, count: number): number {
return ((index % count) + count) % count;
}