feat: 优化 UseIntersectionObserverInfiniteLoading 组件的加载逻辑和模板结构
Some checks failed
/ build-and-deploy-to-vercel (push) Failing after 39s
/ playwright (push) Successful in 2m1s
/ depcheck (push) Successful in 1m30s

This commit is contained in:
严浩
2024-12-11 15:48:35 +08:00
parent aa902ed159
commit dbcc28fb42

View File

@ -65,12 +65,11 @@ const load = async (why?: string) => {
try { try {
const { hasMore } = await props.asyncLoad(++currentPage); const { hasMore } = await props.asyncLoad(++currentPage);
state.value = hasMore ? 'loaded' : 'complete'; state.value = hasMore ? 'loaded' : 'complete';
if (hasMore) { if (hasMore && checkIsVisible(target.value!)) {
await nextTick(); await nextTick();
if (checkIsVisible(target.value!)) { await new Promise((resolve) => setTimeout(resolve, 300));
load('visible after load'); load('visible after load');
} }
}
if (!hasMore) { if (!hasMore) {
pause(); pause();