Skip to content

Commit

Permalink
feat: added scroll tick to update scroll when message sent
Browse files Browse the repository at this point in the history
  • Loading branch information
cbs-l committed Nov 6, 2023
1 parent 8e28e3c commit 2bd1014
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions apps/client/src/lib/components/ChatArea.svelte
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<script lang="ts">
import {tick} from 'svelte';
import type {IMessage} from "$lib/components/Message.svelte";
import FileUploadInput from "./FileUploadInput.svelte";
import EmoteActions from "./EmoteActions.svelte";
Expand Down Expand Up @@ -33,7 +34,7 @@
}
}
function handleMessageSend() {
async function handleMessageSend() {
const formData = new FormData(formEl);
const message = formData.get("message") as string;
Expand All @@ -46,8 +47,9 @@
}];
formEl.reset();
// const height = chatArea.offsetHeight;
console.log("offsetHeight", chatArea.offsetHeight, "scrollHeight", chatArea.scrollHeight, "clientHeight", chatArea.clientHeight)
await tick();
chatArea.scrollTo({top: chatArea.scrollHeight, behavior: "smooth"});
}
</script>
Expand Down

0 comments on commit 2bd1014

Please sign in to comment.