aboutsummaryrefslogtreecommitdiff
path: root/public/js/app.js
diff options
context:
space:
mode:
authorThedro Neely <thedroneely@gmail.com>2020-03-16 22:16:54 -0400
committerThedro Neely <thedroneely@gmail.com>2020-03-16 22:17:19 -0400
commit1f2a18a831680d46ba0e158da3b37a781d826475 (patch)
treee9ac03670dbbbec1ea8c47363cc8462414a47baf /public/js/app.js
parentf798b759eb177337b5f2162918875083bb62297b (diff)
downloadthedroneely.com-1f2a18a831680d46ba0e158da3b37a781d826475.tar.gz
thedroneely.com-1f2a18a831680d46ba0e158da3b37a781d826475.tar.bz2
thedroneely.com-1f2a18a831680d46ba0e158da3b37a781d826475.zip
public/js/app.js: Save page position
Diffstat (limited to 'public/js/app.js')
-rw-r--r--public/js/app.js15
1 files changed, 15 insertions, 0 deletions
diff --git a/public/js/app.js b/public/js/app.js
index 1bf5839..e1303a4 100644
--- a/public/js/app.js
+++ b/public/js/app.js
@@ -13,10 +13,22 @@ function remClass (el, cl) { if (el) { var a = el.className.split(' '); arem(a,
function togClass (el, cl) { if (hasClass(el, cl)) { remClass(el, cl); return; } addClass(el, cl); }
function runOnce(action) { runOnce = function(){}; action(); }
+
+var settings = { pager: {} };
var dropdownInputList = byClass(document, 'dropdown-input');
var dropdownContentList = byClass(document, 'dropdown-content');
var dropdownMenuList = byClass(document, 'dropdown');
+window.onload = function () {
+ if (settings['pager'][window.location.href]) {
+ window.scrollTo(0, settings['pager'][window.location.href]);
+ }
+};
+settings['pager'][window.location.href] = window.pageYOffset;
+if (localStorage['settings']) {
+ settings = JSON.parse(localStorage['settings']);
+}
+
/*
* Hide dropdown
@@ -104,6 +116,9 @@ var scrollReady = 0;
window.onscroll = function() {
+settings['pager'][window.location.href] = window.pageYOffset;
+localStorage['settings'] = JSON.stringify(settings);
+
dropdownHide(dropdownInputList);
var currentPosition = window.pageYOffset;