aboutsummaryrefslogtreecommitdiff
path: root/src/components/timeline/timeline.js
diff options
context:
space:
mode:
authorHenry <spam@hjkos.com>2018-08-12 12:05:08 +0000
committerHenry <spam@hjkos.com>2018-08-12 12:05:08 +0000
commit27adde9887d7205703ed461560f3272f6709b83b (patch)
treeb04030b899850b503097c2df1e7fde2a13043a7f /src/components/timeline/timeline.js
parent3d72c2b964e460762b7ccecc10ddb119fbe80ace (diff)
parentdb6ff4824afa7adca1f3b633278e9ed033d8671d (diff)
Merge branch 'develop' into 'feature/accountHighlight'
# Conflicts: # src/components/user_card_content/user_card_content.vue
Diffstat (limited to 'src/components/timeline/timeline.js')
-rw-r--r--src/components/timeline/timeline.js15
1 files changed, 13 insertions, 2 deletions
diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js
index f24626f9..5c179567 100644
--- a/src/components/timeline/timeline.js
+++ b/src/components/timeline/timeline.js
@@ -13,7 +13,8 @@ const Timeline = {
],
data () {
return {
- paused: false
+ paused: false,
+ unfocused: false
}
},
computed: {
@@ -65,8 +66,15 @@ const Timeline = {
this.fetchFollowers()
}
},
+ mounted () {
+ if (typeof document.hidden !== 'undefined') {
+ document.addEventListener('visibilitychange', this.handleVisibilityChange, false)
+ this.unfocused = document.hidden
+ }
+ },
destroyed () {
window.removeEventListener('scroll', this.scrollLoad)
+ if (typeof document.hidden !== 'undefined') document.removeEventListener('visibilitychange', this.handleVisibilityChange, false)
this.$store.commit('setLoading', { timeline: this.timelineName, value: false })
},
methods: {
@@ -113,6 +121,9 @@ const Timeline = {
(window.innerHeight + window.pageYOffset) >= (height - 750)) {
this.fetchOlderStatuses()
}
+ },
+ handleVisibilityChange () {
+ this.unfocused = document.hidden
}
},
watch: {
@@ -122,7 +133,7 @@ const Timeline = {
}
if (count > 0) {
// only 'stream' them when you're scrolled to the top
- if (window.pageYOffset < 15 && !this.paused) {
+ if (window.pageYOffset < 15 && !this.paused && !this.unfocused) {
this.showNewStatuses()
} else {
this.paused = true