1
0
Fork 0

Fixed pagination bugs

This commit is contained in:
Joe Wroten 2017-05-08 17:45:40 -04:00
parent 892fa05c42
commit d6c6426aed

View file

@ -51,7 +51,8 @@ Vue.component('spell-item', SpellItem)
export default { export default {
computed: { computed: {
pageMax () { pageMax () {
return this.spells.length / this.perPage let trueMax = this.spells.length / this.perPage
return trueMax < 1 ? 1 : trueMax
}, },
pagedSpells () { pagedSpells () {
let min = this.page * this.perPage - this.perPage let min = this.page * this.perPage - this.perPage
@ -59,6 +60,13 @@ export default {
return this.spells.slice(min, max) return this.spells.slice(min, max)
} }
}, },
watch: {
pageMax (newPageMax) {
if (this.page > newPageMax) {
this.page = newPageMax
}
}
},
props: [ props: [
'spells' 'spells'
], ],