Infinite loading (busted)
This commit is contained in:
parent
89ca44069b
commit
90a6824e37
1 changed files with 16 additions and 17 deletions
|
@ -1,13 +1,17 @@
|
||||||
<template>
|
<template>
|
||||||
<div class="list striped no-border">
|
<section
|
||||||
|
is="q-infinite-scroll"
|
||||||
|
:handler="loadMore"
|
||||||
|
class="spell-list list striped no-border"
|
||||||
|
>
|
||||||
<label
|
<label
|
||||||
is="spell-item"
|
is="spell-item"
|
||||||
class="item two-line item-link"
|
class="item two-lines item-link"
|
||||||
v-for="spell in pagedSpells"
|
v-for="spell in pagedSpells"
|
||||||
:spell="spell"
|
:spell="spell"
|
||||||
>
|
>
|
||||||
</label>
|
</label>
|
||||||
</div>
|
</section>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
@ -24,29 +28,18 @@ export default {
|
||||||
],
|
],
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
perPage: 10,
|
loadedPage: 1,
|
||||||
page: 1,
|
|
||||||
sortBy: 'name'
|
sortBy: 'name'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
|
||||||
pageMax (newPageMax) {
|
|
||||||
if (this.page > newPageMax) {
|
|
||||||
this.page = newPageMax
|
|
||||||
}
|
|
||||||
}
|
|
||||||
},
|
|
||||||
computed: {
|
computed: {
|
||||||
dynamicSortBy () {
|
dynamicSortBy () {
|
||||||
return this.search.length >= 3 ? 'sortScore' : this.sortBy
|
return this.search.length >= 3 ? 'sortScore' : this.sortBy
|
||||||
},
|
},
|
||||||
pageMax () {
|
|
||||||
let trueMax = this.filteredSpells.length / this.perPage
|
|
||||||
return trueMax < 1 ? 1 : trueMax
|
|
||||||
},
|
|
||||||
pagedSpells () {
|
pagedSpells () {
|
||||||
|
debugger
|
||||||
return new Query(this.filteredSpells)
|
return new Query(this.filteredSpells)
|
||||||
.paginate(this.page, this.perPage)
|
.paginate(1, this.loadedPage * 20)
|
||||||
.results
|
.results
|
||||||
},
|
},
|
||||||
filteredSpells () {
|
filteredSpells () {
|
||||||
|
@ -55,6 +48,12 @@ export default {
|
||||||
.sort(this.sortBy)
|
.sort(this.sortBy)
|
||||||
.results
|
.results
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
methods: {
|
||||||
|
loadMore (index) {
|
||||||
|
console.log('load more!', index)
|
||||||
|
this.loadedPage += index
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
|
Loading…
Add table
Reference in a new issue