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">
|
<script lang="ts">
|
||||||
import { onMount, tick } from 'svelte';
|
import { onMount, tick } from 'svelte';
|
||||||
|
import { sleep } from '$lib/components/utils';
|
||||||
|
|
||||||
export let onUpdate: () => Promise<any> = Promise.resolve;
|
export let onUpdate: () => Promise<any> = Promise.resolve;
|
||||||
|
|
||||||
@ -10,7 +11,7 @@
|
|||||||
let intersectionElement;
|
let intersectionElement;
|
||||||
function getIntersectionElement() {
|
function getIntersectionElement() {
|
||||||
intersectionElement =
|
intersectionElement =
|
||||||
bodyElem.rows.item(bodyElem.rows.length - 10) || bodyElem.lastElementChild;
|
bodyElem.rows.item(bodyElem.rows.length - 15) || bodyElem.lastElementChild;
|
||||||
}
|
}
|
||||||
|
|
||||||
onMount(async () => {
|
onMount(async () => {
|
||||||
@ -20,13 +21,13 @@
|
|||||||
intersectionObserver = new IntersectionObserver(
|
intersectionObserver = new IntersectionObserver(
|
||||||
async (entries, observer) => {
|
async (entries, observer) => {
|
||||||
if (entries.filter((e) => e.isIntersecting).length === 0 || !entries) return;
|
if (entries.filter((e) => e.isIntersecting).length === 0 || !entries) return;
|
||||||
|
observer.unobserve(intersectionElement!);
|
||||||
|
|
||||||
const rows = bodyElem.rows.length;
|
const rows = bodyElem.rows.length;
|
||||||
|
|
||||||
await onUpdate();
|
await onUpdate();
|
||||||
await tick();
|
await tick();
|
||||||
|
|
||||||
observer.unobserve(intersectionElement!);
|
|
||||||
if (rows === bodyElem.rows.length) return;
|
if (rows === bodyElem.rows.length) return;
|
||||||
getIntersectionElement();
|
getIntersectionElement();
|
||||||
observer.observe(intersectionElement!);
|
observer.observe(intersectionElement!);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user