Skip to content

Commit

Permalink
fix: infinite scroll on mobile
Browse files Browse the repository at this point in the history
  • Loading branch information
khoaxuantu committed Jan 1, 2024
1 parent aad3d9d commit 4f22fa5
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/components/blogs/blogs.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/guestbook/list.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}
Expand Down

0 comments on commit 4f22fa5

Please sign in to comment.