Skip to content

Commit

Permalink
Improve logging UI.
Browse files Browse the repository at this point in the history
  • Loading branch information
hperrin committed Nov 8, 2023
1 parent f42d29f commit dcd7339
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions client/Log.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@
<div
style="display: flex; flex-direction: row; justify-content: end; align-items: center; gap: 1em;"
>
<Button variant="outlined" on:click={scrollToBottom}>
<Label>Scroll to Bottom</Label>
</Button>
<Button variant="outlined" on:click={() => (logs = [])}>
<Label>Clear Log</Label>
</Button>
Expand Down Expand Up @@ -47,13 +50,23 @@
$: if (logs && output) {
const el = output.getElement();
const isHidden = el.clientHeight < 60;
const isScrolledDown =
el.scrollTop >= el.scrollHeight - el.clientHeight - 10;
if (isScrolledDown) {
if (isHidden || isScrolledDown) {
tick().then(() => {
el.scrollTop = el.scrollHeight;
scrollToBottom();
});
}
}
function scrollToBottom() {
if (output) {
const el = output.getElement();
if (el) {
el.scrollTop = el.scrollHeight;
}
}
}
</script>

0 comments on commit dcd7339

Please sign in to comment.