Add an option to initiate fetching older statuses automatically when scrolled 750 pixels or less from the bottom.

This commit is contained in:
Shpuld Shpuldson 2017-06-03 18:51:55 +03:00
parent e901e064de
commit 65646c5a12
5 changed files with 17 additions and 0 deletions

View file

@ -20,6 +20,8 @@ const Timeline = {
const credentials = store.state.users.currentUser.credentials
const showImmediately = this.timeline.visibleStatuses.length === 0
window.onscroll = this.scrollLoad
timelineFetcher.fetchAndUpdate({
store,
credentials,
@ -42,6 +44,11 @@ const Timeline = {
older: true,
showImmediately: true
}).then(() => store.commit('setLoading', { timeline: this.timelineName, value: false }))
},
scrollLoad (e) {
if (this.timeline.loading === false && this.$store.state.config.autoLoad && (window.innerHeight + window.pageYOffset) >= (document.body.scrollHeight - 750)) {
this.fetchOlderStatuses()
}
}
}
}