Closed Akari1987 closed 4 years ago
Sorry I solved by myself. Using conditional event listener like below.
<infinite-loading @infinite="infiniteStatus !== 'pending' ? infiniteHandler($refs.infiniteLoading.stateChanger) : $refs.infiniteLoading.status = 0" ref="infiniteLoading">
// detected the distance so need to hide spinner but don't emit infiniteHandler when status is pending.
Hi, thanks for awesome library. I'm implementing 3 times infiniteHandler after that pending infinite and add 'load more' button. like below
<infinite-loading @infinite="infiniteHandler" ref="infiniteLoading"> <v-btn v-show="infiniteStatus === 'pending'" @click="infiniteLoadMore" text>Load More...
data() { return { page: 1, pageLamda: 0, pageLoadLimit: 3, infiniteStatus: "loading" commentDatas: [] } }
infiniteHandler($state) { axios.get('/api&page=' + this.page).then((res) => { if(res.data.length) { this.commentDatas = this.commentDatas.concat(res.data);; this.page++; this.pageLambda++ if(this.pageLambda === this.pageLoadRemit) { this.infiniteStatus = "pending" this.pageLambda = 0 this.$refs.infiniteLoading.status = 0 // hide spinner } else { $state.loaded(); } } else { $state.complete(); this.infiniteStatus = "complete" } }); }
infiniteLoadMore() { this.$refs.infiniteLoading.attemptLoad() this.infiniteStatus = "loading" }
This works almost as I expected, But showing 'load more' button, and scroll page, emit infiniteHandler. Because the distance may be detected.
So Is it possible to add request pending state for disable to watch distance?
Sorry for my wrong English. Best regards.