frontend: fix autoscroll breaking message loading

This commit is contained in:
hippoz 2022-04-20 17:53:20 +03:00
parent e267ca4fc4
commit addfddd3ac
No known key found for this signature in database
GPG key ID: 7C52899193467641

View file

@ -14,7 +14,7 @@
afterUpdate(() => { afterUpdate(() => {
if (shouldAutoscroll && scrollTarget) { if (shouldAutoscroll && scrollTarget) {
scrollTarget.scrollIntoView(); scrollTarget.scrollTo(0, scrollTarget.scrollHeight);
} }
}); });
@ -43,12 +43,11 @@
} }
</style> </style>
<div class="messages-container" on:scroll={ onScroll }> <div class="messages-container" on:scroll={ onScroll } bind:this={ scrollTarget }>
{#each $messages as message (message.id)} {#each $messages as message (message.id)}
<div> <div>
<b>{ message.author_username }</b> <b>{ message.author_username }</b>
<span>{ message.content }</span> <span>{ message.content }</span>
</div> </div>
{/each} {/each}
<div bind:this={ scrollTarget }></div>
</div> </div>