mirror of
https://github.com/nkanaev/yarr.git
synced 2025-05-24 00:33:14 +00:00
fix: load more items to prevent scroll lock
This commit is contained in:
parent
8ceab03cd7
commit
684bc25b83
@ -419,7 +419,7 @@ var vm = new Vue({
|
|||||||
}
|
}
|
||||||
|
|
||||||
this.loading.items = true
|
this.loading.items = true
|
||||||
return api.items.list(query).then(function(data) {
|
api.items.list(query).then(function(data) {
|
||||||
if (loadMore) {
|
if (loadMore) {
|
||||||
vm.items = vm.items.concat(data.list)
|
vm.items = vm.items.concat(data.list)
|
||||||
} else {
|
} else {
|
||||||
@ -427,14 +427,24 @@ var vm = new Vue({
|
|||||||
}
|
}
|
||||||
vm.itemsHasMore = data.has_more
|
vm.itemsHasMore = data.has_more
|
||||||
vm.loading.items = false
|
vm.loading.items = false
|
||||||
|
|
||||||
|
// load more if there's some space left at the bottom of the item list.
|
||||||
|
vm.$nextTick(function() {
|
||||||
|
if (vm.itemsHasMore && !vm.loading.items && vm.itemListCloseToBottom()) {
|
||||||
|
vm.refreshItems(true)
|
||||||
|
}
|
||||||
|
})
|
||||||
})
|
})
|
||||||
},
|
},
|
||||||
|
itemListCloseToBottom: function() {
|
||||||
|
var el = this.$refs.itemlist
|
||||||
|
var closeToBottom = (el.scrollHeight - el.scrollTop - el.offsetHeight) < 50
|
||||||
|
return closeToBottom
|
||||||
|
},
|
||||||
loadMoreItems: function(event, el) {
|
loadMoreItems: function(event, el) {
|
||||||
if (!this.itemsHasMore) return
|
if (!this.itemsHasMore) return
|
||||||
|
|
||||||
if (this.loading.items) return
|
if (this.loading.items) return
|
||||||
var closeToBottom = (el.scrollHeight - el.scrollTop - el.offsetHeight) < 50
|
if (this.itemListCloseToBottom()) this.refreshItems(true)
|
||||||
if (closeToBottom) this.refreshItems(true)
|
|
||||||
},
|
},
|
||||||
markItemsRead: function() {
|
markItemsRead: function() {
|
||||||
var query = this.getItemsQuery()
|
var query = this.getItemsQuery()
|
||||||
|
Loading…
x
Reference in New Issue
Block a user