Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/kc0bfv/autophugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl <kc0bfv@gmail.com>2022-10-22 23:57:13 +0300
committerKarl <kc0bfv@gmail.com>2022-10-22 23:57:13 +0300
commit42686321acd7a6ce0d837627883e7c601b017c9c (patch)
tree79394e5120da64c9697020b80f2337dab2996f98
parent53ec5df42fb741afc1bbcade3070bc7a13c0e36c (diff)
Looking at img on a page no longer changes history
-rw-r--r--assets/js/main.js17
1 files changed, 15 insertions, 2 deletions
diff --git a/assets/js/main.js b/assets/js/main.js
index 9ea4436..520177f 100644
--- a/assets/js/main.js
+++ b/assets/js/main.js
@@ -239,10 +239,23 @@
},
callbacks: {
change: function() {
- window.location.hash = this.currItem.el.attr("id");
+ // Replace the current history state with a URL with
+ // a new hash part. The hash part tells the site to load
+ // a specific image in fullscreen. Replacing the history
+ // causes the back and forward buttons to now go to the
+ // URL with the hash version... Simply changing the URL
+ // will instead cause a browser to add a new URL to the
+ // history with the hash part. Then if you look at a ton
+ // of images on one page, they'll all clutter up your history
+ // and you'll have to back through them all to get back to
+ // what seems like the previous page. I think this
+ // replaceState version is a better behavior.
+ const hash = "#" + this.currItem.el.attr("id");
+ window.history.replaceState(undefined, undefined, hash);
},
close: function() {
- window.location.hash = "";
+ // Clear the hash part without adding new things to the history
+ window.history.replaceState(undefined, undefined, "");
},
},
fixedContentPos: true,