Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix scrolling chat when in the background #4979

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this is actually what the biggest problem was. It removed the scroll-to-bottom button, although it wasn't scrolled to the bottom

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