mirror of
https://github.com/elk-zone/elk.git
synced 2024-12-05 03:59:59 +03:00
fix: autoload new items when at top of timeline
This commit is contained in:
parent
5c5143d2c9
commit
264c796e2f
1 changed files with 23 additions and 3 deletions
|
@ -9,14 +9,34 @@ const { paginator, stream } = defineProps<{
|
||||||
}>()
|
}>()
|
||||||
|
|
||||||
const virtualScroller = $(computedEager(() => useFeatureFlags().experimentalVirtualScroll))
|
const virtualScroller = $(computedEager(() => useFeatureFlags().experimentalVirtualScroll))
|
||||||
|
const updater = ref()
|
||||||
|
const observer = new IntersectionObserver((entries) => {
|
||||||
|
const [entry] = entries
|
||||||
|
if (entry.isIntersecting) {
|
||||||
|
observer.unobserve(entry.target)
|
||||||
|
setTimeout(() => {
|
||||||
|
(entry.target as HTMLButtonElement)?.click()
|
||||||
|
}, 50)
|
||||||
|
}
|
||||||
|
}, { threshold: 0.5 })
|
||||||
|
|
||||||
|
watch(updater, (v) => {
|
||||||
|
if (v)
|
||||||
|
observer.observe(v)
|
||||||
|
})
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
<template>
|
<template>
|
||||||
<CommonPaginator v-bind="{ paginator, stream }" :virtual-scroller="virtualScroller">
|
<CommonPaginator v-bind="{ paginator, stream }" :virtual-scroller="virtualScroller">
|
||||||
<template #updater="{ number, update }">
|
<template #updater="{ number, update }">
|
||||||
<button py-4 border="b base" flex="~ col" p-3 w-full text-primary font-bold @click="update">
|
<button
|
||||||
{{ $t('timeline.show_new_items', [number]) }}
|
v-if="number"
|
||||||
</button>
|
ref="updater"
|
||||||
|
style="background: repeating-linear-gradient(to right,var(--c-primary) 0%,var(--c-primary-active) 100%)"
|
||||||
|
absolute h-1 w-full animate-pulse
|
||||||
|
:aria-title="$t('timeline.show_new_items', [number])"
|
||||||
|
@click="update"
|
||||||
|
/>
|
||||||
</template>
|
</template>
|
||||||
<template #default="{ item, active }">
|
<template #default="{ item, active }">
|
||||||
<template v-if="virtualScroller">
|
<template v-if="virtualScroller">
|
||||||
|
|
Loading…
Reference in a new issue