Skip to content

feat(frontend): add wrap-around navigation setting#230

Merged
lstein merged 2 commits into
masterfrom
lstein/feat/wrap-navigation
May 17, 2026
Merged

feat(frontend): add wrap-around navigation setting#230
lstein merged 2 commits into
masterfrom
lstein/feat/wrap-navigation

Conversation

@lstein
Copy link
Copy Markdown
Owner

@lstein lstein commented May 17, 2026

Summary

  • Adds a "Wrap Around During Navigation" checkbox to Slideshow Settings (default off, persisted via localStorage).
  • When off, scrolling forward from the last image / backward from the first stops at the boundary in both album and search modes.
  • When on, scrolling past either end continues seamlessly in the other direction.

Why

Previous behaviour was asymmetric: forward-from-last silently wrapped because (idx + 1) % total returns 0, but backward-from-first stopped because JS's % returns negative for negative dividends. The new logic uses positive modulo ((raw % total) + total) % total so both directions wrap consistently when the setting is on, and returns null at the bounds when off.

The two dedup guards (exists in addSlideByIndex and prevExists in slidePrevTransitionEnd) were also blocking wrap navigation past the first lap — once every globalIndex in the album / result set had been loaded into the swiper, subsequent forward/backward steps silently no-op'd. Removed for linear navigation; preserved for shuffle mode (still needed when the random picker exhausts attempts in a small pool — covered by swiper-shuffle.test.js).

resolveOffset returns null when total <= 1 in wrap mode (nothing to wrap to).

Toggling the checkbox calls resetAllSlides() so any stale wrap-neighbour slides accumulated under the old setting are cleared.

Test plan

  • With wrap off, navigate to the last image — forward stops, doesn't wrap.
  • With wrap off, navigate to the first image — backward stops, doesn't wrap.
  • With wrap on, scroll forward indefinitely — wraps repeatedly past the end without getting stuck partway.
  • With wrap on, scroll backward indefinitely — wraps repeatedly past the start.
  • Repeat both wrap-on cases inside search-mode results.
  • Toggle the checkbox while at the boundary — wrap state immediately reflects the new setting (no stale wrap-neighbours linger when turning off; wrap-neighbour gets loaded when turning on).
  • Setting survives a page reload.

lstein and others added 2 commits May 16, 2026 22:38
Adds a "Wrap Around During Navigation" checkbox to Slideshow Settings
(default off). When off, the slideshow stops at the first and last image
of the album or search results. When on, scrolling past either end
continues seamlessly in the other direction.

resolveOffset now uses positive modulo for both directions (the previous
`%` behaviour silently wrapped forward but not backward because of JS
negative-modulo semantics). The dedup guards that returned early when a
globalIndex was already in the swiper DOM are removed for linear
navigation — they were blocking wrap-around past the first lap once
every globalIndex had appeared at least once. Shuffle-mode dedup is
preserved.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@lstein lstein enabled auto-merge (squash) May 17, 2026 02:47
@lstein lstein merged commit 607d42e into master May 17, 2026
6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant