From 65646c5a125126bca97b0f5bf5f43c9544fd2cb2 Mon Sep 17 00:00:00 2001 From: Shpuld Shpuldson Date: Sat, 3 Jun 2017 18:51:55 +0300 Subject: Add an option to initiate fetching older statuses automatically when scrolled 750 pixels or less from the bottom. --- src/components/timeline/timeline.js | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'src/components/timeline/timeline.js') 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() + } } } } -- cgit v1.2.3-70-g09d2