upgraded DMs, and fixed bugs

This commit is contained in:
MathMan05 2024-09-07 17:35:15 -05:00
parent 1502dbec17
commit 512cc95ab4
15 changed files with 161 additions and 72 deletions

View file

@ -24,14 +24,17 @@ class InfiniteScroller {
scroll.classList.add("flexttb", "scroller");
div.appendChild(scroll);
this.div = div;
this.beenloaded = false;
//this.interval=setInterval(this.updatestuff.bind(this,true),100);
this.scroll = scroll;
this.div.addEventListener("scroll", _ => {
this.checkscroll();
if (this.scroll)
this.scrollTop = this.scroll.scrollTop;
this.watchForChange();
});
this.scroll.addEventListener("scroll", _ => {
this.checkscroll();
if (this.timeout === null) {
this.timeout = setTimeout(this.updatestuff.bind(this), 300);
}
@ -40,6 +43,8 @@ class InfiniteScroller {
{
let oldheight = 0;
new ResizeObserver(_ => {
this.checkscroll();
const func = this.snapBottom();
this.updatestuff();
const change = oldheight - div.offsetHeight;
if (change > 0 && this.scroll) {
@ -47,6 +52,7 @@ class InfiniteScroller {
}
oldheight = div.offsetHeight;
this.watchForChange();
func();
}).observe(div);
}
new ResizeObserver(this.watchForChange.bind(this)).observe(scroll);
@ -54,13 +60,21 @@ class InfiniteScroller {
this.updatestuff();
await this.watchForChange().then(_ => {
this.updatestuff();
this.beenloaded = true;
});
return div;
}
beenloaded = false;
scrollBottom;
scrollTop;
needsupdate = true;
averageheight = 60;
checkscroll() {
if (this.beenloaded && this.scroll && !document.body.contains(this.scroll)) {
this.scroll = null;
this.div = null;
}
}
async updatestuff() {
this.timeout = null;
if (!this.scroll)