summaryrefslogtreecommitdiffstats
path: root/public/js/slideshow.js
diff options
context:
space:
mode:
authorKen D'Ambrosio <ken@jots.org>2026-05-11 20:17:05 +0000
committerKen D'Ambrosio <ken@jots.org>2026-05-11 20:17:05 +0000
commite1e93e4ded6d8f8bfa12a99b12abe7e7e3b29775 (patch)
tree7eb99e0b8440ebdd33ea343273d401897c25c958 /public/js/slideshow.js
parentb40e95ca17f8c9f17af5f475d001c8ec33728e6d (diff)
Fix slideshow timer burst when returning from background tab
Use Page Visibility API to cancel the timer when the tab hides and reschedule fresh on return, so no queued ticks fire in a burst. Also fix stale #photo= → ?photo= in stage click-through. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
Diffstat (limited to 'public/js/slideshow.js')
-rw-r--r--public/js/slideshow.js11
1 files changed, 10 insertions, 1 deletions
diff --git a/public/js/slideshow.js b/public/js/slideshow.js
index a732962..7df0955 100644
--- a/public/js/slideshow.js
+++ b/public/js/slideshow.js
@@ -139,6 +139,15 @@ function onFsChange() {
document.addEventListener('fullscreenchange', onFsChange);
document.addEventListener('webkitfullscreenchange', onFsChange);
+// Pause timer while tab is hidden; reschedule fresh on return so no burst catch-up.
+document.addEventListener('visibilitychange', () => {
+ if (document.hidden) {
+ clearTimeout(ssTimer);
+ } else if (ssPlaying) {
+ ssSchedule();
+ }
+});
+
// Click/tap anywhere in the stage → open photo in its album lightbox.
// Skip when the video element is the target so its native controls still work.
// Read the live src attribute rather than ssIdx, which updates ahead of the
@@ -150,7 +159,7 @@ document.getElementById('ss-stage').addEventListener('click', ev => {
if (!e) return;
const lastSlash = e.file_rel.lastIndexOf('/');
const albumRel = lastSlash >= 0 ? e.file_rel.slice(0, lastSlash) : '';
- window.location.href = '/browse/' + (albumRel ? albumRel + '/' : '') + '#photo=' + encodeURIComponent(e.name);
+ window.location.href = '/browse/' + (albumRel ? albumRel + '/' : '') + '?photo=' + encodeURIComponent(e.name);
});
// ── Keyboard & touch ───────────────────────────────────────────────────────────