aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThedro Neely <thedroneely@gmail.com>2022-04-03 02:23:50 -0400
committerThedro Neely <thedroneely@gmail.com>2022-04-03 02:23:50 -0400
commit218a42551c4e7a03b0c76bf70843934674ccfd3f (patch)
tree07dcf5ea97718e872e02ecdfc8d6b7b71c654a26
parent58b4eb4226c2ca44c7aa50c771b34e3bef6ae7a1 (diff)
downloadthedroneely.com-218a42551c4e7a03b0c76bf70843934674ccfd3f.tar.gz
thedroneely.com-218a42551c4e7a03b0c76bf70843934674ccfd3f.tar.bz2
thedroneely.com-218a42551c4e7a03b0c76bf70843934674ccfd3f.zip
public/js/app: Scroll to location hash
Chrome does the opposite of Firefox on location hash refresh. https://superuser.com/questions/1471522/how-can-i-return-to-a-named-anchor-after-scrolling-in-chrome/1471549#1471549 Pass empty string on title in window.history.replaceState just to be safe.
-rw-r--r--public/js/app.js3
1 files changed, 2 insertions, 1 deletions
diff --git a/public/js/app.js b/public/js/app.js
index 3c6d91f..cbf5f07 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -14,7 +14,7 @@ function runOnce(action) { runOnce = function(){}; action(); }
* Remove url query string
*/
var url = window.location.href.split('?')[0];
-window.history.replaceState(null, null, url);
+window.history.replaceState(null, '', url);
/**
* Remove url hash to store in pager
@@ -32,6 +32,7 @@ window.addEventListener('load', function(event) {
if (window.location.href.indexOf("#") >= 0) {
settings['pager'][url] = window.pageYOffset;
localStorage['settings'] = JSON.stringify(settings);
+ document.getElementById(location.hash.slice(1)).scrollIntoView()
return;
}
if (settings['pager'][url] > 0) { window.scrollTo(0, settings['pager'][url]); return; }