1
0
mirror of https://github.com/amir20/dozzle.git synced 2025-12-24 06:28:42 +01:00

chore: refactors code by moving loader to a log entry (#3951)

This commit is contained in:
Amir Raminfar
2025-06-06 09:28:57 -07:00
committed by GitHub
parent 7257e35f1b
commit 9db559c9ce
9 changed files with 94 additions and 77 deletions

View File

@@ -0,0 +1,29 @@
<template>
<div ref="root" class="flex min-h-[1px] flex-1 content-center justify-center p-2">
<span class="loading loading-bars loading-md text-primary" v-show="isLoading"></span>
</div>
</template>
<script lang="ts" setup>
import { LoadMoreLogEntry } from "@/models/LogEntry";
const { logEntry } = defineProps<{
logEntry: LoadMoreLogEntry;
}>();
const isLoading = ref(false);
const root = ref<HTMLElement>();
useIntersectionObserver(root, async (entries) => {
if (entries[0].intersectionRatio <= 0) return;
if (isLoading.value) return;
const scrollingParent = root.value?.closest("[data-scrolling]") || document.documentElement;
const previousHeight = scrollingParent.scrollHeight;
isLoading.value = true;
await logEntry.loadMore();
isLoading.value = false;
await nextTick();
scrollingParent.scrollTop += scrollingParent.scrollHeight - previousHeight;
});
</script>
<style scoped></style>