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 /assets | |
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 'assets')
-rw-r--r-- | assets/js/index.js | 14 |
1 files changed, 12 insertions, 2 deletions
diff --git a/assets/js/index.js b/assets/js/index.js index b4f0bcb..d6e325a 100644 --- a/assets/js/index.js +++ b/assets/js/index.js @@ -55,7 +55,7 @@ const fragmentClear = (entries)=>{ for(let entry = 0; entry < entries.length; entry++){ if (self.location.hash) { - self.history.pushState(null, "", url1); + self.history.replaceState(null, "", url1); } } }; @@ -74,15 +74,25 @@ }; self.addEventListener("DOMContentLoaded", function() { scrollRestore(settings1, url1); - fragmentRelease(fragmentClear); self.addEventListener("click", function(event) { const up = document.getElementById("top"); const back = document.getElementById("back"); backTrack(back, up, event); }); }); + let scrolls = 0; + let once = (action)=>{ + once = function() {}; + action(); + }; self.addEventListener("scroll", function() { scrollTrack(settings1, url1); + if (scrolls > 3) { + once(function() { + fragmentRelease(fragmentClear); + }); + } + scrolls++; }); })(); (function() { |