diff options
author | tdro <tdro@noreply.example.com> | 2023-09-16 04:50:54 -0400 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2023-09-16 04:50:54 -0400 |
commit | 4bbbed1adcd354719eda137ac4a3c71da23e929d (patch) | |
tree | 2a131bbfdf12db16af91e084e027a415f1534de4 /static | |
parent | 344acdcd6245496feb440cd362b8aa9fdb8ad776 (diff) | |
download | canory-4bbbed1adcd354719eda137ac4a3c71da23e929d.tar.gz canory-4bbbed1adcd354719eda137ac4a3c71da23e929d.tar.bz2 canory-4bbbed1adcd354719eda137ac4a3c71da23e929d.zip |
static/js/pager: Cover click and touchstart
DOMContentLoaded fragment
Diffstat (limited to 'static')
-rw-r--r-- | static/js/pager.ts | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/static/js/pager.ts b/static/js/pager.ts index c685cb1..cb7f8a4 100644 --- a/static/js/pager.ts +++ b/static/js/pager.ts @@ -14,16 +14,14 @@ const scrollRestore = function (url) { if (history.scrollRestoration) history.scrollRestoration = "manual"; - if (localStorage[key]) { - settings = JSON.parse(localStorage[key]); - } + if (localStorage[key]) settings = JSON.parse(localStorage[key]); const fragment = document.getElementById(location.hash.slice(1)); const fragmentInURL = self.location.hash.length > 0; if (fragmentInURL && document.body.contains(fragment)) { settings["pager"][url] = self.pageYOffset; localStorage[key] = JSON.stringify(settings); fragment.scrollIntoView(); - self.addEventListener("load", function () { + self.addEventListener("DOMContentLoaded", function () { fragment.scrollIntoView(); }); return; @@ -63,11 +61,13 @@ }); }); - self.addEventListener("scroll", function () { - scrollTrack(url); - }); - self.addEventListener("hashchange", function () { scrollRestore(url); }); + + ["click", "touchstart", "scroll"].forEach(function (event) { + self.addEventListener(event, function (event) { + scrollTrack(url); + }); + }); })(); |