Flesh out people tab

This commit is contained in:
Jon Staab
2024-10-01 14:55:33 -07:00
parent 3e06c36563
commit 65b699d49d
11 changed files with 228 additions and 52 deletions
+11 -6
View File
@@ -17,26 +17,31 @@ export const copyToClipboard = (text: string) => {
}
type ScrollerOpts = {
onScroll: () => any
element: Element
threshold?: number
reverse?: boolean
delay?: number
}
export const createScroller = (
loadMore: () => Promise<void>,
{delay = 1000, threshold = 2000, reverse = false}: ScrollerOpts = {},
) => {
export const createScroller = ({
onScroll,
element,
delay = 1000,
threshold = 2000,
reverse = false,
}: ScrollerOpts) => {
let done = false
const check = async () => {
// While we have empty space, fill it
const {scrollY, innerHeight} = window
const {scrollHeight, scrollTop} = document.querySelector('.max-h-screen')!
const {scrollHeight, scrollTop} = element
const offset = Math.abs(scrollTop || scrollY)
const shouldLoad = offset + innerHeight + threshold > scrollHeight
// Only trigger loading the first time we reach the threshold
if (shouldLoad) {
await loadMore()
await onScroll()
}
// No need to check all that often