Made it so that unfocused tab doesn't autostream posts when scrolled to the top
This commit is contained in:
parent
32fd108e97
commit
d3d5a84868
@ -13,7 +13,8 @@ const Timeline = {
|
|||||||
],
|
],
|
||||||
data () {
|
data () {
|
||||||
return {
|
return {
|
||||||
paused: false
|
paused: false,
|
||||||
|
unfocused: false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
computed: {
|
computed: {
|
||||||
@ -65,8 +66,15 @@ const Timeline = {
|
|||||||
this.fetchFollowers()
|
this.fetchFollowers()
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted () {
|
||||||
|
if (typeof document.hidden !== 'undefined') {
|
||||||
|
document.addEventListener('visibilitychange', this.handleVisibilityChange, false)
|
||||||
|
this.unfocused = document.hidden
|
||||||
|
}
|
||||||
|
},
|
||||||
destroyed () {
|
destroyed () {
|
||||||
window.removeEventListener('scroll', this.scrollLoad)
|
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 })
|
this.$store.commit('setLoading', { timeline: this.timelineName, value: false })
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
@ -113,6 +121,9 @@ const Timeline = {
|
|||||||
(window.innerHeight + window.pageYOffset) >= (height - 750)) {
|
(window.innerHeight + window.pageYOffset) >= (height - 750)) {
|
||||||
this.fetchOlderStatuses()
|
this.fetchOlderStatuses()
|
||||||
}
|
}
|
||||||
|
},
|
||||||
|
handleVisibilityChange () {
|
||||||
|
this.unfocused = document.hidden
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
watch: {
|
watch: {
|
||||||
@ -122,7 +133,7 @@ const Timeline = {
|
|||||||
}
|
}
|
||||||
if (count > 0) {
|
if (count > 0) {
|
||||||
// only 'stream' them when you're scrolled to the top
|
// 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()
|
this.showNewStatuses()
|
||||||
} else {
|
} else {
|
||||||
this.paused = true
|
this.paused = true
|
||||||
|
Loading…
Reference in New Issue
Block a user