From a7a0fee815e692b9f0606a280aac7caceaaa1a75 Mon Sep 17 00:00:00 2001 From: Florian Greistorfer Date: Mon, 23 Mar 2026 14:57:40 +0100 Subject: [PATCH] add pageshow handler --- templates/functionality.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/templates/functionality.js b/templates/functionality.js index 4f75fb4..6343165 100644 --- a/templates/functionality.js +++ b/templates/functionality.js @@ -15,6 +15,7 @@ class PhotoGallery { this.insertPath = this.insertPath.bind(this); this.lightMode = this.lightMode.bind(this); this.onLoad = this.onLoad.bind(this); + this.onPageShow = this.onPageShow.bind(this); this.openSwipe = this.openSwipe.bind(this); this.parseHierarchicalTags = this.parseHierarchicalTags.bind(this); this.prefetch = this.prefetch.bind(this); @@ -191,7 +192,6 @@ class PhotoGallery { } onLoad() { - this.detectDarkMode(); document.querySelectorAll(".tagtoggle").forEach((toggle) => { toggle.addEventListener("mouseup", (event) => { event.stopPropagation(); @@ -208,6 +208,10 @@ class PhotoGallery { window.addEventListener("scroll", this.scrollFunction); } + onPageShow() { + this.detectDarkMode(); + } + openSwipe(imgIndex) { const options = { index: imgIndex }; const gallery = new PhotoSwipe(this.pswpElement, PhotoSwipeUI_Default, this.shown, options); @@ -528,6 +532,11 @@ class PhotoGallery { } init() { + if (window.addEventListener) { + window.addEventListener("pageshow", this.onPageShow, false); + } else if (window.attachEvent) { + window.attachEvent("pageshow", this.onPageShow); + } if (window.addEventListener) { window.addEventListener("load", this.onLoad, false); } else if (window.attachEvent) {