diff --git a/src/components/SearchResults.vue b/src/components/SearchResults.vue index ef2b7918..b3198ef5 100644 --- a/src/components/SearchResults.vue +++ b/src/components/SearchResults.vue @@ -8,7 +8,7 @@ style="background: #0b0e0f" class="uk-width-1-2 uk-width-1-3@s uk-width-1-4@m uk-width-1-5@l uk-width-1-6@xl" v-bind:key="result.url" - v-for="result in results" + v-for="result in results.items" >
(this.results = json) ); + }, + handleScroll() { + if (this.loading || !this.results || !this.results.nextpage) return; + if ( + window.innerHeight + window.scrollY >= + document.body.offsetHeight - window.innerHeight + ) { + this.loading = true; + fetch( + Constants.BASE_URL + + "/nextpage/search" + + "?url=" + + encodeURIComponent(this.results.nextpage) + + "&id=" + + encodeURIComponent(this.results.id) + + "&q=" + + this.$route.params.search_query + ) + .then(body => body.json()) + .then(json => { + this.results.nextpage = json.nextpage; + this.results.id = json.id; + this.loading = false; + json.items.map(stream => + this.results.items.push(stream) + ); + }); + } } } };