add pageshow handler

This commit is contained in:
2026-03-23 14:57:40 +01:00
committed by Florian Greistorfer
parent cedb187c28
commit a7a0fee815

View File

@@ -15,6 +15,7 @@ class PhotoGallery {
this.insertPath = this.insertPath.bind(this); this.insertPath = this.insertPath.bind(this);
this.lightMode = this.lightMode.bind(this); this.lightMode = this.lightMode.bind(this);
this.onLoad = this.onLoad.bind(this); this.onLoad = this.onLoad.bind(this);
this.onPageShow = this.onPageShow.bind(this);
this.openSwipe = this.openSwipe.bind(this); this.openSwipe = this.openSwipe.bind(this);
this.parseHierarchicalTags = this.parseHierarchicalTags.bind(this); this.parseHierarchicalTags = this.parseHierarchicalTags.bind(this);
this.prefetch = this.prefetch.bind(this); this.prefetch = this.prefetch.bind(this);
@@ -191,7 +192,6 @@ class PhotoGallery {
} }
onLoad() { onLoad() {
this.detectDarkMode();
document.querySelectorAll(".tagtoggle").forEach((toggle) => { document.querySelectorAll(".tagtoggle").forEach((toggle) => {
toggle.addEventListener("mouseup", (event) => { toggle.addEventListener("mouseup", (event) => {
event.stopPropagation(); event.stopPropagation();
@@ -208,6 +208,10 @@ class PhotoGallery {
window.addEventListener("scroll", this.scrollFunction); window.addEventListener("scroll", this.scrollFunction);
} }
onPageShow() {
this.detectDarkMode();
}
openSwipe(imgIndex) { openSwipe(imgIndex) {
const options = { index: imgIndex }; const options = { index: imgIndex };
const gallery = new PhotoSwipe(this.pswpElement, PhotoSwipeUI_Default, this.shown, options); const gallery = new PhotoSwipe(this.pswpElement, PhotoSwipeUI_Default, this.shown, options);
@@ -528,6 +532,11 @@ class PhotoGallery {
} }
init() { init() {
if (window.addEventListener) {
window.addEventListener("pageshow", this.onPageShow, false);
} else if (window.attachEvent) {
window.attachEvent("pageshow", this.onPageShow);
}
if (window.addEventListener) { if (window.addEventListener) {
window.addEventListener("load", this.onLoad, false); window.addEventListener("load", this.onLoad, false);
} else if (window.attachEvent) { } else if (window.attachEvent) {