diff options
author | tdro <tdro@noreply.example.com> | 2022-09-02 08:32:34 -0400 |
---|---|---|
committer | tdro <tdro@noreply.example.com> | 2022-09-02 08:32:34 -0400 |
commit | 35269ef701767cfa6474984c73ae6d19e40e3d71 (patch) | |
tree | 41885df5356e7d9970dda072600fe63dc07cc05f /static | |
parent | 9f9a5d6aa541437a2459de1bf12f7bd9e8ef37ab (diff) | |
download | canory-35269ef701767cfa6474984c73ae6d19e40e3d71.tar.gz canory-35269ef701767cfa6474984c73ae6d19e40e3d71.tar.bz2 canory-35269ef701767cfa6474984c73ae6d19e40e3d71.zip |
static/js/pager: Delay intersection observer from scroll event once
Replace instead of append
Diffstat (limited to 'static')
-rw-r--r-- | static/js/pager.ts | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/static/js/pager.ts b/static/js/pager.ts index 68708cc..7231161 100644 --- a/static/js/pager.ts +++ b/static/js/pager.ts @@ -56,7 +56,7 @@ const fragmentClear = (entries) => { for (let entry = 0; entry < entries.length; entry++) { if (self.location.hash) { - self.history.pushState(null, "", url); + self.history.replaceState(null, "", url); } } }; @@ -78,7 +78,6 @@ self.addEventListener("DOMContentLoaded", function () { scrollRestore(settings, url); - fragmentRelease(fragmentClear); self.addEventListener("click", function (event) { const up = document.getElementById("top"); const back = document.getElementById("back"); @@ -86,7 +85,20 @@ }); }); + let scrolls = 0; + + let once = (action) => { + once = function () {}; + action(); + }; + self.addEventListener("scroll", function () { scrollTrack(settings, url); + if (scrolls > 3) { + once(function () { + fragmentRelease(fragmentClear); + }); + } + scrolls++; }); })(); |