increase pagination prefetch elements
All checks were successful
delpoy / build-and-deploy (push) Successful in 1m27s
All checks were successful
delpoy / build-and-deploy (push) Successful in 1m27s
This commit is contained in:
parent
bd33727aa6
commit
df91278db0
@ -5,44 +5,45 @@
|
|||||||
|
|
||||||
let bodyElem: HTMLTableSectionElement;
|
let bodyElem: HTMLTableSectionElement;
|
||||||
|
|
||||||
function intersectionViewer() {
|
let intersectionObserver: IntersectionObserver;
|
||||||
let updating = false;
|
|
||||||
let intersectionElement =
|
|
||||||
bodyElem.rows.item(bodyElem.rows.length - 5) || bodyElem.lastElementChild;
|
|
||||||
|
|
||||||
new IntersectionObserver(
|
let intersectionElement;
|
||||||
async (entries, observer) => {
|
function getIntersectionElement() {
|
||||||
if (entries.filter((e) => e.isIntersecting).length === 0 || updating) return;
|
intersectionElement =
|
||||||
|
bodyElem.rows.item(bodyElem.rows.length - 10) || bodyElem.lastElementChild;
|
||||||
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 () => {
|
onMount(async () => {
|
||||||
await onUpdate();
|
await onUpdate();
|
||||||
await tick();
|
await tick();
|
||||||
|
|
||||||
new MutationObserver((entries) => {
|
intersectionObserver = new IntersectionObserver(
|
||||||
if (entries.filter((e) => e.removedNodes.length > 0).length === 0) return;
|
async (entries, observer) => {
|
||||||
|
if (entries.filter((e) => e.isIntersecting).length === 0 || !entries) return;
|
||||||
|
|
||||||
intersectionViewer();
|
const rows = bodyElem.rows.length;
|
||||||
|
|
||||||
|
await onUpdate();
|
||||||
|
await tick();
|
||||||
|
|
||||||
|
observer.unobserve(intersectionElement!);
|
||||||
|
if (rows === bodyElem.rows.length) return;
|
||||||
|
getIntersectionElement();
|
||||||
|
observer.observe(intersectionElement!);
|
||||||
|
},
|
||||||
|
{ threshold: 1.0 }
|
||||||
|
);
|
||||||
|
|
||||||
|
new MutationObserver((entries) => {
|
||||||
|
if (entries.filter((e) => e.removedNodes.length > 0).length === 0 || !entries) return;
|
||||||
|
|
||||||
|
intersectionObserver.unobserve(intersectionElement!);
|
||||||
|
getIntersectionElement();
|
||||||
|
intersectionObserver.observe(intersectionElement!);
|
||||||
}).observe(bodyElem, { childList: true });
|
}).observe(bodyElem, { childList: true });
|
||||||
|
|
||||||
intersectionViewer();
|
getIntersectionElement();
|
||||||
|
intersectionObserver.observe(intersectionElement!);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user