From da6e8308c6497881c2644dffb6b3062eb16f215e Mon Sep 17 00:00:00 2001 From: MathMan05 Date: Mon, 29 Jul 2024 14:16:07 -0500 Subject: [PATCH] infinate scroller fix --- .dist/infiniteScroller.js | 39 ++++++++++++++++++++----------------- webpage/infiniteScroller.ts | 32 ++++++++++++++++-------------- 2 files changed, 38 insertions(+), 33 deletions(-) diff --git a/.dist/infiniteScroller.js b/.dist/infiniteScroller.js index 610f892..3cf1cf3 100644 --- a/.dist/infiniteScroller.js +++ b/.dist/infiniteScroller.js @@ -59,23 +59,8 @@ class InfiniteScroller { this.scroll.scrollTop = this.scroll.scrollHeight; } } - async watchForChange() { - if (this.currrunning) { - return; - } - else { - this.currrunning = true; - } + async watchForTop() { let again = false; - if (!this.div) { - this.currrunning = false; - return; - } - /* - if(this.scrollTop===0){ - this.scrollTop=10; - } - */ if (this.scrollTop === 0) { this.scrollTop = 1; this.scroll.scrollTop = 1; @@ -100,6 +85,12 @@ class InfiniteScroller { await this.destroyFromID(html[1]); this.scrollTop -= 60; } + if (again) { + await this.watchForTop(); + } + } + async watchForBottom() { + let again = false; const scrollBottom = this.scrollBottom; if (scrollBottom < this.minDist) { const previd = this.HTMLElements.at(-1)[1]; @@ -124,10 +115,22 @@ class InfiniteScroller { await this.destroyFromID(html[1]); this.scrollBottom -= 60; } - this.currrunning = false; if (again) { - await this.watchForChange(); + await this.watchForBottom(); } + } + async watchForChange() { + if (this.currrunning) { + return; + } + else { + this.currrunning = true; + } + if (!this.div) { + this.currrunning = false; + return; + } + await Promise.allSettled([this.watchForBottom(), this.watchForTop()]); this.currrunning = false; } async focus(id, flash = true) { diff --git a/webpage/infiniteScroller.ts b/webpage/infiniteScroller.ts index 4a41a50..6d5d1b4 100644 --- a/webpage/infiniteScroller.ts +++ b/webpage/infiniteScroller.ts @@ -61,19 +61,8 @@ class InfiniteScroller{ this.scroll.scrollTop=this.scroll.scrollHeight; } } - async watchForChange():Promise{ - if(this.currrunning){ - return; - }else{ - this.currrunning=true; - } + private async watchForTop():Promise{ let again=false; - if(!this.div){this.currrunning=false;return} - /* - if(this.scrollTop===0){ - this.scrollTop=10; - } - */ if(this.scrollTop===0){ this.scrollTop=1; this.scroll.scrollTop=1; @@ -98,6 +87,12 @@ class InfiniteScroller{ await this.destroyFromID(html[1]); this.scrollTop-=60; } + if(again){ + await this.watchForTop(); + } + } + async watchForBottom():Promise{ + let again=false; const scrollBottom = this.scrollBottom; if(scrollBottom{ + if(this.currrunning){ + return; + }else{ + this.currrunning=true; + } + if(!this.div){this.currrunning=false;return} + await Promise.allSettled([this.watchForBottom(),this.watchForTop()]) this.currrunning=false; } async focus(id:string,flash=true){