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.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) {