Refine infinite scroll behavior
This commit is contained in:
parent
2f513e2b39
commit
a20bb7f927
@ -15,10 +15,6 @@ export default function MorePhotos({
|
||||
}) {
|
||||
const router = useRouter();
|
||||
|
||||
if (prefetch) {
|
||||
router.prefetch(path);
|
||||
}
|
||||
|
||||
const [isPending, startTransition] = useTransition();
|
||||
|
||||
const buttonRef = useRef<HTMLButtonElement>(null);
|
||||
@ -27,6 +23,12 @@ export default function MorePhotos({
|
||||
router.push(path, { scroll: false });
|
||||
}), [router, path]);
|
||||
|
||||
useEffect(() => {
|
||||
if (prefetch) {
|
||||
router.prefetch(path);
|
||||
}
|
||||
}, [router, path, prefetch]);
|
||||
|
||||
useEffect(() => {
|
||||
const observer = new IntersectionObserver(e => {
|
||||
if (triggerOnView && e[0].isIntersecting) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user