maybe fix overfetching
All checks were successful
delpoy / build-and-deploy (push) Successful in 1m35s
All checks were successful
delpoy / build-and-deploy (push) Successful in 1m35s
This commit is contained in:
parent
df91278db0
commit
f461f6db77
@ -1,5 +1,6 @@
|
||||
<script lang="ts">
|
||||
import { onMount, tick } from 'svelte';
|
||||
import { sleep } from '$lib/components/utils';
|
||||
|
||||
export let onUpdate: () => Promise<any> = Promise.resolve;
|
||||
|
||||
@ -10,7 +11,7 @@
|
||||
let intersectionElement;
|
||||
function getIntersectionElement() {
|
||||
intersectionElement =
|
||||
bodyElem.rows.item(bodyElem.rows.length - 10) || bodyElem.lastElementChild;
|
||||
bodyElem.rows.item(bodyElem.rows.length - 15) || bodyElem.lastElementChild;
|
||||
}
|
||||
|
||||
onMount(async () => {
|
||||
@ -20,13 +21,13 @@
|
||||
intersectionObserver = new IntersectionObserver(
|
||||
async (entries, observer) => {
|
||||
if (entries.filter((e) => e.isIntersecting).length === 0 || !entries) return;
|
||||
observer.unobserve(intersectionElement!);
|
||||
|
||||
const rows = bodyElem.rows.length;
|
||||
|
||||
await onUpdate();
|
||||
await tick();
|
||||
|
||||
observer.unobserve(intersectionElement!);
|
||||
if (rows === bodyElem.rows.length) return;
|
||||
getIntersectionElement();
|
||||
observer.observe(intersectionElement!);
|
||||
|
Loading…
x
Reference in New Issue
Block a user