Compare commits

...

1 commit

Author SHA1 Message Date
Daniel Roe
264c796e2f
fix: autoload new items when at top of timeline 2022-11-29 15:25:45 +00:00

View file

@ -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">