update admin pagination
All checks were successful
delpoy / build-and-deploy (push) Successful in 1m16s

This commit is contained in:
2024-11-28 01:44:35 +01:00
parent 676bfc23d8
commit bd33727aa6
6 changed files with 214 additions and 226 deletions

View File

@@ -0,0 +1,51 @@
<script lang="ts">
import { onMount, tick } from 'svelte';
export let onUpdate: () => Promise<any> = Promise.resolve;
let bodyElem: HTMLTableSectionElement;
function intersectionViewer() {
let updating = false;
let intersectionElement =
bodyElem.rows.item(bodyElem.rows.length - 5) || bodyElem.lastElementChild;
new IntersectionObserver(
async (entries, observer) => {
if (entries.filter((e) => e.isIntersecting).length === 0 || updating) return;
updating = true;
const rows = bodyElem.rows.length;
await onUpdate();
await tick();
observer.disconnect();
updating = false;
if (rows === bodyElem.rows.length) return;
intersectionViewer();
},
{ threshold: 1.0 }
).observe(intersectionElement!);
}
onMount(async () => {
await onUpdate();
await tick();
new MutationObserver((entries) => {
if (entries.filter((e) => e.removedNodes.length > 0).length === 0) return;
intersectionViewer();
}).observe(bodyElem, { childList: true });
intersectionViewer();
});
</script>
<tbody bind:this={bodyElem}>
<slot />
</tbody>