update admin pagination
All checks were successful
delpoy / build-and-deploy (push) Successful in 1m16s
All checks were successful
delpoy / build-and-deploy (push) Successful in 1m16s
This commit is contained in:
@@ -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>
|
||||
Reference in New Issue
Block a user