Fix show more button appearing in unwanted situations

This commit is contained in:
Marco Realacci 2022-12-15 14:54:48 +01:00
parent 3e4c28123e
commit fba46f28ff
3 changed files with 6 additions and 6 deletions

View file

@ -32,7 +32,7 @@ export default {
return return
} }
if (response.data.length == 0) this.data_ended = true; if (response.data.length == 0 || response.data.length < this.limit) this.data_ended = true;
else this.stream_data = this.stream_data.concat(response.data); else this.stream_data = this.stream_data.concat(response.data);
this.loading = false; this.loading = false;
}, },

View file

@ -49,7 +49,7 @@ export default {
return return
} }
if (response.data.length == 0) this.data_ended = true; if (response.data.length == 0 || response.data.length < this.limit) this.data_ended = true;
else this.stream_data = this.stream_data.concat(response.data); else this.stream_data = this.stream_data.concat(response.data);
this.loading = false; this.loading = false;
@ -61,7 +61,7 @@ export default {
scroll() { scroll() {
window.onscroll = () => { window.onscroll = () => {
let bottomOfWindow = Math.max(window.pageYOffset, document.documentElement.scrollTop, document.body.scrollTop) + window.innerHeight >= document.documentElement.offsetHeight - 5 let bottomOfWindow = Math.max(window.pageYOffset, document.documentElement.scrollTop, document.body.scrollTop) + window.innerHeight >= document.documentElement.offsetHeight - 5
if (bottomOfWindow && !this.data_ended) { if (bottomOfWindow && !this.data_ended) {
this.start_idx += this.limit this.start_idx += this.limit
this.loadMore() this.loadMore()

View file

@ -39,10 +39,10 @@ export default {
}, },
scroll () { scroll () {
window.onscroll = () => { window.onscroll = () => {
let bottomOfWindow = Math.max(window.pageYOffset, document.documentElement.scrollTop, document.body.scrollTop) + window.innerHeight === document.documentElement.offsetHeight let bottomOfWindow = Math.max(window.pageYOffset, document.documentElement.scrollTop, document.body.scrollTop) + window.innerHeight >= document.documentElement.offsetHeight - 5
if (bottomOfWindow && !this.dataEnded) { if (bottomOfWindow && !this.dataEnded) {
this.startIdx += this.limit; this.startIdx += this.limit
this.loadContent(); this.loadContent()
} }
} }
}, },