grain.social is a photo sharing platform built on atproto. grain.social
atproto photography appview
48
fork

Configure Feed

Select the types of activity you want to include in your feed.

at main 17 lines 550 B view raw
1/** Svelte action: calls `onIntersect` when the element scrolls into view. 2 * The callback should guard against re-entry (e.g. check `!isFetchingNextPage`). */ 3export function infiniteScroll(node: HTMLElement, onIntersect: () => void) { 4 const observer = new IntersectionObserver( 5 (entries) => { 6 if (entries[0]?.isIntersecting) { 7 onIntersect() 8 } 9 }, 10 { rootMargin: '200px' }, 11 ) 12 observer.observe(node) 13 return { 14 update(newFn: () => void) { onIntersect = newFn }, 15 destroy() { observer.disconnect() }, 16 } 17}