From 4f22fa59e08dfad473ff109ac66ecffb920a7951 Mon Sep 17 00:00:00 2001 From: khoaxuantu <68913255+khoaxuantu@users.noreply.github.com> Date: Mon, 1 Jan 2024 15:37:34 +0700 Subject: [PATCH] fix: infinite scroll on mobile --- src/components/blogs/blogs.tsx | 2 +- src/components/guestbook/list.tsx | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/components/blogs/blogs.tsx b/src/components/blogs/blogs.tsx index 388f281..7f029f7 100644 --- a/src/components/blogs/blogs.tsx +++ b/src/components/blogs/blogs.tsx @@ -48,7 +48,7 @@ export function BlogsList(props: {blogInfoList: { dictKey: string; date: string; const scrollHeight = document.documentElement.scrollHeight; const clientHeight = document.documentElement.clientHeight; - if (scrollTop + clientHeight >= scrollHeight && hasMore) { + if (scrollTop + clientHeight >= scrollHeight - 100 && hasMore) { setStartId(startId => startId + blogsNum); } } diff --git a/src/components/guestbook/list.tsx b/src/components/guestbook/list.tsx index 8c75ea6..daea227 100644 --- a/src/components/guestbook/list.tsx +++ b/src/components/guestbook/list.tsx @@ -42,7 +42,7 @@ function GuestbookList({maxGuests} : {maxGuests: number}) { const scrollHeight = document.documentElement.scrollHeight; const clientHeight = document.documentElement.clientHeight; - if (scrollTop + clientHeight >= scrollHeight && hasMore) { + if (scrollTop + clientHeight >= scrollHeight - 100 && hasMore) { setStartId(startId => startId + messageNums); } }