aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorShpuld Shpuldson <shpuld@gmail.com>2017-11-02 16:26:17 +0200
committerShpuld Shpuldson <shpuld@gmail.com>2017-11-02 16:26:17 +0200
commit10bc83018c5c2ef56b2d1b28eb58e2c466693a39 (patch)
treec4895ffccb57d885123ea146641341e3f6a4533b /src
parent63473964f8bf94a0930f3bf4724a23642ef9a18d (diff)
Deregister scroll listener properly, only fetch more if timeline is visible.
Diffstat (limited to 'src')
-rw-r--r--src/components/timeline/timeline.js10
1 files changed, 8 insertions, 2 deletions
diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js
index bd80d57b..6968bc6f 100644
--- a/src/components/timeline/timeline.js
+++ b/src/components/timeline/timeline.js
@@ -33,7 +33,7 @@ const Timeline = {
const credentials = store.state.users.currentUser.credentials
const showImmediately = this.timeline.visibleStatuses.length === 0
- window.onscroll = this.scrollLoad
+ window.addEventListener('scroll', this.scrollLoad)
timelineFetcher.fetchAndUpdate({
store,
@@ -50,6 +50,9 @@ const Timeline = {
this.fetchFollowers()
}
},
+ destroyed () {
+ window.removeEventListener('scroll', this.scrollLoad)
+ },
methods: {
showNewStatuses () {
this.$store.commit('showNewStatuses', { timeline: this.timelineName })
@@ -80,7 +83,10 @@ const Timeline = {
},
scrollLoad (e) {
let height = Math.max(document.body.offsetHeight, document.body.scrollHeight)
- if (this.timeline.loading === false && this.$store.state.config.autoLoad && (window.innerHeight + window.pageYOffset) >= (height - 750)) {
+ if (this.timeline.loading === false &&
+ this.$store.state.config.autoLoad &&
+ this.$el.offsetHeight > 0 &&
+ (window.innerHeight + window.pageYOffset) >= (height - 750)) {
this.fetchOlderStatuses()
}
}