Skip to content

Commit

Permalink
Merge pull request #4979 from nextcloud/bugfix/noid/fix-scrolling-cha…
Browse files Browse the repository at this point in the history
…t-when-in-background

Fix scrolling chat when in the background
  • Loading branch information
marcoambrosini committed Jan 20, 2021
2 parents 60e0887 + a0e0f0e commit 1a7a81e
Showing 1 changed file with 18 additions and 5 deletions.
23 changes: 18 additions & 5 deletions src/components/MessagesList/MessagesList.vue
Expand Up @@ -588,11 +588,24 @@ export default {
*/
smoothScrollToBottom() {
this.$nextTick(function() {
this.scroller.scrollTo({
top: this.scroller.scrollHeight,
behavior: 'smooth',
})
this.setChatScrolledToBottom(true)
if (this.$store.getters.windowIsVisible()) {
// scrollTo is used when the user is watching
this.scroller.scrollTo({
top: this.scroller.scrollHeight,
behavior: 'smooth',
})
this.setChatScrolledToBottom(true)
} else {
// Otherwise we jump half a message and stop autoscrolling, so the user can read up
if (this.scroller.scrollHeight - this.scroller.scrollTop - this.scroller.offsetHeight < 40) {
// Single new line from the previous author is 35px so scroll half a line
this.scroller.scrollTop += 10
} else {
// Single new line from the new author is 75px so scroll half an avatar
this.scroller.scrollTop += 40
}
this.setChatScrolledToBottom(false)
}
})
},
/**
Expand Down

0 comments on commit 1a7a81e

Please sign in to comment.