aboutsummaryrefslogtreecommitdiff
path: root/src/components/timeline/timeline.js
diff options
context:
space:
mode:
authorshpuld <shp@cock.li>2017-11-13 01:06:48 +0200
committershpuld <shp@cock.li>2017-11-13 01:06:48 +0200
commit46f23b7de7a5e27dd4f9f13f063d263fbb1ec85d (patch)
tree5675373b1df6019b6b52d8d2116b1223f0740081 /src/components/timeline/timeline.js
parentc682a4b007cc55ce627e7c7331443905e473c4a7 (diff)
Add an option to automatically show new posts when scrolled to the top, also add fade-in animation for posts.
Diffstat (limited to 'src/components/timeline/timeline.js')
-rw-r--r--src/components/timeline/timeline.js24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/components/timeline/timeline.js b/src/components/timeline/timeline.js
index 6968bc6f..613b8a34 100644
--- a/src/components/timeline/timeline.js
+++ b/src/components/timeline/timeline.js
@@ -11,6 +11,11 @@ const Timeline = {
'userId',
'tag'
],
+ data () {
+ return {
+ paused: false
+ }
+ },
computed: {
timelineError () { return this.$store.state.statuses.error },
followers () {
@@ -21,6 +26,9 @@ const Timeline = {
},
viewing () {
return this.timeline.viewing
+ },
+ newStatusCount () {
+ return this.timeline.newStatusCount
}
},
components: {
@@ -56,6 +64,7 @@ const Timeline = {
methods: {
showNewStatuses () {
this.$store.commit('showNewStatuses', { timeline: this.timelineName })
+ this.paused = false
},
fetchOlderStatuses () {
const store = this.$store
@@ -90,6 +99,21 @@ const Timeline = {
this.fetchOlderStatuses()
}
}
+ },
+ watch: {
+ newStatusCount (count) {
+ if (!this.$store.state.config.streaming) {
+ return
+ }
+ if (count > 0) {
+ // only 'stream' them when you're scrolled to the top
+ if (window.pageYOffset < 15 && !this.paused) {
+ this.showNewStatuses()
+ } else {
+ this.paused = true
+ }
+ }
+ }
}
}