Skip to content

useInfiniteScroll for document scroll #4656

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

Open
4 tasks done
MickL opened this issue Mar 10, 2025 · 3 comments
Open
4 tasks done

useInfiniteScroll for document scroll #4656

MickL opened this issue Mar 10, 2025 · 3 comments

Comments

@MickL
Copy link

MickL commented Mar 10, 2025

Clear and concise description of the problem

Lets say we have a website that shows a list of products. When scrolling the document, new products should be loaded before reaching the end of the products wrapper.

Currently this doesnt seem to be possible with useInfiniteScroll: It can only be used with a scrollable html element. Of course we can use document as the element but it will not load new products before reaching the end of the products wrapper, but instead before reaching the end of the document (which probably includes footer and other stuff below the products wrapper).

The following shows the problem:
https://stackblitz.com/edit/vitejs-vite-5xmosl1v?file=src%2FApp.vue

Suggested solution

One solution might be to add a second prop to useInfiniteScroll that is the element to check for the end-position. One could then use document as el and additionally set the products wrapper and useInfiniteScroll could then check if distance betweend document scroll and end of wrapper element is reached.

Another solution might be to place a trigger component at the end of the products list, that will be used for checking the distance.

Alternative

No response

Additional context

No response

Validations

@OrbisK
Copy link
Collaborator

OrbisK commented Mar 13, 2025

I think what you can do is:

useInfiniteScroll(el, loadData, { distance: 1000 });

increasing the distance will get the effect you want.

@MickL
Copy link
Author

MickL commented Mar 13, 2025

Increasing the distance is a very unreliable way. For example on Desktop the footer area is wide and low while on mobile it is narrow and high. Also one might have other, dynamic, content under the infinite scroll content.

@ilyaliao
Copy link
Member

Maybe you could consider using canLoadMore?

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

No branches or pull requests

3 participants
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy