How to handle auto scrolling in a chat app when new message comes in?
So this is an example what i currently have
Now this works but I want to make it such that when the user has scrolled up to read previous messages it doesn't auto scroll. I can't quite figure out how to go about that in solid.
2 Replies
OK I've come up with something, just don't know if it's the best
It works but it doesn't feel right, Is there a better way to handle this?
Yea its a couple design decisions in here,
One thing I would do is just keep the user interaction separate, so either state to represent whether or not the user is scrolling or the amount they did.. scroll delta etc.. then with whatever other information you can still et the actual scroll height
As for the computed scroll the way you have it is fine, or can use something like https://developer.mozilla.org/en-US/docs/Web/CSS/overflow-anchor. Both ways combined with tracking the user interaction should be a bit cleaner