logs: fix autoscrolling

This commit is contained in:
Johannes Zellner
2023-07-12 14:16:48 +02:00
parent f48b04ca87
commit 9b6957b52f
+5 -6
View File
@@ -16,12 +16,10 @@
</TopBar>
</template>
<template #body>
<div class="logs-container" ref="logsContainer">
<div v-for="line in logLines" :key="line.id" class="log-line">
<span class="time">{{ line.time }}</span><span v-html="line.html"></span>
</div>
<div ref="scrollAnchor" class="bottom-spacer"></div>
<div v-for="line in logLines" :key="line.id" class="log-line">
<span class="time">{{ line.time }}</span><span v-html="line.html"></span>
</div>
<div ref="scrollAnchor" class="bottom-spacer"></div>
</template>
</MainLayout>
</template>
@@ -126,7 +124,8 @@ export default {
this.logsModel.stream((id, time, html) => {
this.logLines.push({ id, time, html});
const tmp = this.$refs.logsContainer;
const tmp = document.getElementsByClassName('cloudron-layout-body')[0];
if (!tmp) return;
const autoScroll = tmp.scrollTop > (tmp.scrollHeight - tmp.clientHeight - 34);
if (autoScroll) setTimeout(() => this.$refs.scrollAnchor.scrollIntoView(false), 1);