Infinite scroll not working
See original GitHub issueDescribe the bug
I’m trying to use infinite scroll, however the provided examples don’t seem to work.
<template>
<div
class="flex flex-col gap-2 p-4 w-300px h-300px m-auto overflow-y-scroll bg-gray-500/5 rounded"
ref="el"
>
<div v-for="item in data" :key="item">
{{ item }}
</div>
</div>
</template>
<script setup lang="ts">
import { ref } from "vue";
import { useInfiniteScroll } from "@vueuse/core";
const el = ref<HTMLElement | null>(null);
useInfiniteScroll(el, () => console.log("fetch"), { distance: 100 }); // nothing logged to console
</script>
Reproduction
https://stackblitz.com/edit/vitejs-vite-srqqu3
System Info
System:
OS: Linux 5.18 Arch Linux
CPU: (12) x64 AMD Ryzen 5 3600 6-Core Processor
Memory: 19.16 GB / 31.27 GB
Container: Yes
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.3.0 - /usr/bin/node
Yarn: 1.22.19 - /usr/bin/yarn
npm: 8.5.5 - /usr/bin/npm
npmPackages:
@vueuse/components: ^8.6.0 => 8.6.0
@vueuse/core: ^8.6.0 => 8.6.0
vue: ^3.2.36 => 3.2.36
Used Package Manager
npm
Validations
- Follow our Code of Conduct
- Read the Contributing Guidelines.
- Read the docs.
- Check that there isn’t already an issue that reports the same bug to avoid creating a duplicate.
- Make sure this is a VueUse issue and not a framework-specific issue. For example, if it’s a Vue SFC related bug, it should likely be reported to https://github.com/vuejs/core instead.
- Check that this is a concrete bug. For Q&A open a GitHub Discussion.
- The provided reproduction is a minimal reproducible example of the bug.
Issue Analytics
- State:
- Created a year ago
- Comments:10 (3 by maintainers)
Top Results From Across the Web
ngInfiniteScroll not working - Stack Overflow
Scroll event is only triggered on page load, after that nothing seems to trigger it. Can anyone please shed some light. I tried...
Read more >Infinite scroll stopped working - WordPress.org
Hello,. Since yesterday the infinite scroll option has stopped working. The website went live over 1 month ago and it had been working...
Read more >Issues for Views Infinite Scroll | Drupal.org
Title Status Priority Cate...
Allow setting scroll threshold and delay Reviewed & tested by the community Normal Featu...
Parametrize scrollThreshold field Needs review Normal Featu...
AJAX...
Read more >Infinite scroll not working - Get Help - Frontity Community Forum
It is when the user scrolls down, the infinite scroll triggers, he/she clicks on a post and finally goes back to the last...
Read more >I did pagination but infinite scroll not working? - ProcessWire
Hi, i implemented pagination for my site : http://www.diana-homes.com Now i want infinite scroll for home page. I did all the things ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
I accomplished this using ‘useIntersectionObserver’
My hacky solution for now is once I fetch data, I check if the container still isn’t scrollable, it’ll make another call (assuming there is still more data to fetch), e.g:
Full logic: