You can try like this:
.chat-container .chat-message:last-child
{
scroll-snap-align: end;
}
Additionally, you can run a MutationObserver on the scroll container and when there is new content - your event handler will scroll to the bottom of the container.
If you're using Vue.js - then you can take advantage of the following directive:
// Monitors an element and scrolls to the bottom if a new child is added (always:false = prevent scrolling if user manually scrolled up)
// <ul class="messages" v-chat-scroll="{always: false}">
// <li class="message" v-for="n in messages">{{ n }}</li>
// </ul>
Vue.directive('chat-scroll',
{
bind: function(el, binding)
{
var timeout, scrolled = false;
el.addEventListener('scroll', function(e)
{
if (timeout) window.clearTimeout(timeout);
timeout = window.setTimeout(function()
{
scrolled = el.scrollTop + el.clientHeight + 1 < el.scrollHeight;
}, 200);
});
(new MutationObserver(function(e)
{
var config = binding.value || {};
var pause = config.always === false && scrolled;
if (pause || e[e.length - 1].addedNodes.length != 1) return;
scrollToBottom(el);
})).observe(el, {childList: true});
},
inserted: scrollToBottom
});