diff options
| author | Shpuld Shpuldson <shpuld@gmail.com> | 2017-06-03 18:51:55 +0300 |
|---|---|---|
| committer | Shpuld Shpuldson <shpuld@gmail.com> | 2017-06-03 18:51:55 +0300 |
| commit | 65646c5a125126bca97b0f5bf5f43c9544fd2cb2 (patch) | |
| tree | 7a8ea99e41d3d59a3e692f6b53419addbc3b8eaa /src/components/timeline/timeline.js | |
| parent | e901e064de8f961450129013978ca72666a7e7e8 (diff) | |
Add an option to initiate fetching older statuses automatically when scrolled 750 pixels or less from the bottom.
Diffstat (limited to 'src/components/timeline/timeline.js')
| -rw-r--r-- | src/components/timeline/timeline.js | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js index d5a9adcc..6070e442 100644 --- a/src/components/timeline/timeline.js +++ b/src/components/timeline/timeline.js @@ -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() + } } } } |
