infinate scroller fix
This commit is contained in:
parent
f553e1418d
commit
da6e8308c6
2 changed files with 38 additions and 33 deletions
|
@ -59,23 +59,8 @@ class InfiniteScroller {
|
||||||
this.scroll.scrollTop = this.scroll.scrollHeight;
|
this.scroll.scrollTop = this.scroll.scrollHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async watchForChange() {
|
async watchForTop() {
|
||||||
if (this.currrunning) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.currrunning = true;
|
|
||||||
}
|
|
||||||
let again = false;
|
let again = false;
|
||||||
if (!this.div) {
|
|
||||||
this.currrunning = false;
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
if(this.scrollTop===0){
|
|
||||||
this.scrollTop=10;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if (this.scrollTop === 0) {
|
if (this.scrollTop === 0) {
|
||||||
this.scrollTop = 1;
|
this.scrollTop = 1;
|
||||||
this.scroll.scrollTop = 1;
|
this.scroll.scrollTop = 1;
|
||||||
|
@ -100,6 +85,12 @@ class InfiniteScroller {
|
||||||
await this.destroyFromID(html[1]);
|
await this.destroyFromID(html[1]);
|
||||||
this.scrollTop -= 60;
|
this.scrollTop -= 60;
|
||||||
}
|
}
|
||||||
|
if (again) {
|
||||||
|
await this.watchForTop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async watchForBottom() {
|
||||||
|
let again = false;
|
||||||
const scrollBottom = this.scrollBottom;
|
const scrollBottom = this.scrollBottom;
|
||||||
if (scrollBottom < this.minDist) {
|
if (scrollBottom < this.minDist) {
|
||||||
const previd = this.HTMLElements.at(-1)[1];
|
const previd = this.HTMLElements.at(-1)[1];
|
||||||
|
@ -124,10 +115,22 @@ class InfiniteScroller {
|
||||||
await this.destroyFromID(html[1]);
|
await this.destroyFromID(html[1]);
|
||||||
this.scrollBottom -= 60;
|
this.scrollBottom -= 60;
|
||||||
}
|
}
|
||||||
this.currrunning = false;
|
|
||||||
if (again) {
|
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;
|
this.currrunning = false;
|
||||||
}
|
}
|
||||||
async focus(id, flash = true) {
|
async focus(id, flash = true) {
|
||||||
|
|
|
@ -61,19 +61,8 @@ class InfiniteScroller{
|
||||||
this.scroll.scrollTop=this.scroll.scrollHeight;
|
this.scroll.scrollTop=this.scroll.scrollHeight;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
async watchForChange():Promise<void>{
|
private async watchForTop():Promise<void>{
|
||||||
if(this.currrunning){
|
|
||||||
return;
|
|
||||||
}else{
|
|
||||||
this.currrunning=true;
|
|
||||||
}
|
|
||||||
let again=false;
|
let again=false;
|
||||||
if(!this.div){this.currrunning=false;return}
|
|
||||||
/*
|
|
||||||
if(this.scrollTop===0){
|
|
||||||
this.scrollTop=10;
|
|
||||||
}
|
|
||||||
*/
|
|
||||||
if(this.scrollTop===0){
|
if(this.scrollTop===0){
|
||||||
this.scrollTop=1;
|
this.scrollTop=1;
|
||||||
this.scroll.scrollTop=1;
|
this.scroll.scrollTop=1;
|
||||||
|
@ -98,6 +87,12 @@ class InfiniteScroller{
|
||||||
await this.destroyFromID(html[1]);
|
await this.destroyFromID(html[1]);
|
||||||
this.scrollTop-=60;
|
this.scrollTop-=60;
|
||||||
}
|
}
|
||||||
|
if(again){
|
||||||
|
await this.watchForTop();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
async watchForBottom():Promise<void>{
|
||||||
|
let again=false;
|
||||||
const scrollBottom = this.scrollBottom;
|
const scrollBottom = this.scrollBottom;
|
||||||
if(scrollBottom<this.minDist){
|
if(scrollBottom<this.minDist){
|
||||||
|
|
||||||
|
@ -123,11 +118,18 @@ class InfiniteScroller{
|
||||||
await this.destroyFromID(html[1]);
|
await this.destroyFromID(html[1]);
|
||||||
this.scrollBottom-=60;
|
this.scrollBottom-=60;
|
||||||
}
|
}
|
||||||
|
|
||||||
this.currrunning=false;
|
|
||||||
if(again){
|
if(again){
|
||||||
await this.watchForChange();
|
await this.watchForBottom();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
async watchForChange():Promise<void>{
|
||||||
|
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;
|
this.currrunning=false;
|
||||||
}
|
}
|
||||||
async focus(id:string,flash=true){
|
async focus(id:string,flash=true){
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue