mirror of
https://github.com/nagisa77/OpenIsle.git
synced 2026-08-10 21:31:00 +00:00
feat: add paginated tag loading
This commit is contained in:
@@ -25,6 +25,8 @@ const props = defineProps({
|
||||
rootMargin: { type: String, default: '200px 0px' },
|
||||
/** 触发阈值 */
|
||||
threshold: { type: Number, default: 0 },
|
||||
/** 自定义 IntersectionObserver 根元素(默认为视口) */
|
||||
root: { type: Object, default: null },
|
||||
})
|
||||
|
||||
const isLoading = ref(false)
|
||||
@@ -58,7 +60,11 @@ const startObserver = () => {
|
||||
isLoading.value = false
|
||||
}
|
||||
},
|
||||
{ root: null, rootMargin: props.rootMargin, threshold: props.threshold },
|
||||
{
|
||||
root: props.root || null,
|
||||
rootMargin: props.rootMargin,
|
||||
threshold: props.threshold,
|
||||
},
|
||||
)
|
||||
if (sentinel.value) io.observe(sentinel.value)
|
||||
}
|
||||
@@ -76,6 +82,13 @@ watch(
|
||||
},
|
||||
)
|
||||
|
||||
watch(
|
||||
() => props.root,
|
||||
() => {
|
||||
nextTick(startObserver)
|
||||
},
|
||||
)
|
||||
|
||||
/** 父组件可选择性调用,用于外部强制重置(一般直接用 :key 重建更简单) */
|
||||
const reset = () => {
|
||||
done.value = false
|
||||
|
||||
Reference in New Issue
Block a user