Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

✨ Load pages and ensure scrollbar is always visible #760

Conversation

MontaGhanmy
Copy link
Collaborator

No description provided.

@MontaGhanmy MontaGhanmy self-assigned this Dec 3, 2024
@MontaGhanmy MontaGhanmy added this to the v1.0.6 milestone Dec 3, 2024
@ericlinagora
Copy link
Contributor

I'm just a bit curious about some more esoteric scenarios: you load a first page, it has a scrollbar, font too big you zoom out, no more scroll bar =D I think we can let it be since a refresh fixes it

@MontaGhanmy
Copy link
Collaborator Author

I'm just a bit curious about some more esoteric scenarios: you load a first page, it has a scrollbar, font too big you zoom out, no more scroll bar =D I think we can let it be since a refresh fixes it

@ericlinagora I just updated it so it does try to ensure the scroll bar is in view when the window is re-sized;

if (scrollTop > 0 && scrollTop + clientHeight >= scrollHeight) {
await loadNextPage(parentId);
}
};

useEffect(() => {
if(!loading) scrollViwer.current?.addEventListener('scroll', handleScroll, { passive: true });
if (!loading)
scrollViewer.current?.addEventListener('scroll', handleScroll, { passive: true });
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks good to me, but have you considered replacing the scroll event with the Intersection Observer API in the future? I saw that the scroll event triggers even when the scrollbar hasn’t reached the target point.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I didn't know about that API, looks great thanks

@MontaGhanmy MontaGhanmy merged commit 9bc8b29 into main Dec 9, 2024
7 checks passed
@ericlinagora ericlinagora deleted the 755-when-the-first-page-of-items-loads-without-needing-a-scrollbar-no-way-to-get-to-second-page branch December 13, 2024 21:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

When the first page of items loads without needing a scrollbar, no way to get to second page
3 participants