Autoscrolling
If we're going to build a frontend we might as well do it right. In this section, we're going to add an autoscrolling feature. So if a new message comes in, it is visible inside of the messages panel. Now right away this is not a problem. I type an a
, I hit enter, and it shows up. However, as we get further down the list, you'll see the messages start to disappear down the bottom of the bar:
Now I can indeed scroll down to see the most recent messages, but it would be nice if I'm automatically scrolled to the most recent message. So if a new message comes in like 123
, I'm automatically brought to the bottom.
Now, obviously, if someone does scroll up to read an old message, we're going to want to keep them there; we're not going to want to scroll them to the bottom, that would be just as annoying as not being able to see the new messages in the first place. This means that we're going to go ahead and calculate a threshold. If someone can see that last message, we're going to go...