mattmezza / vue-beautiful-chat

A simple and beautiful Vue chat component backend agnostic, fully customisable and extendable.
https://matteo.merola.co/vue-beautiful-chat/
MIT License
1.5k stars 441 forks source link

Scroll to bottom behaviour #219

Closed BJJLangedijk closed 2 years ago

BJJLangedijk commented 3 years ago

Previously there was a hard coded value determining if the chat was able to scroll down. I am not sure where this value is coming from, but it seemed to me that even in the demo application it would not always scroll (scroll a tiny bit up in the window and shouldScrollToBottom() would be false.

With this change it checks based on the clientHeight. This also solves issues in our application where we have styled things differently and the chat window/message list has a different height.

I added another check if the clientHeight is available since it would be 0 if the chat is closed.

a-kriya commented 3 years ago

@BJJLangedijk Thanks for the PR and describing the issue and your code.

scroll a tiny bit up in the window and shouldScrollToBottom() would be false

I'm finding the output to be opposite, where scrolling back a tiny bit causes scrollable to be true and scrolling back further (~180px in the demo app) will cause scrollable to be false (as scrollTop will turn to be less than this.$refs.scrollList.scrollHeight - 600).

Although I did not write the current logic, I think it's saying that scrolling further up implies a deliberate action by the user where they may be trying to see older messages so they should not be forced all the way down on an update, while if the message list is only scrolled up a tiny bit, scrolling it to the bottom will not be jarring. @mattmezza hasn't been active here lately, but only he would be able to confirm -- I see you're from 🇳🇱, too, so would you mind knocking on his door : ]

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.