vueuse: useInfiniteScroll v10 behavior differs from v9 - Scrolling to the edge triggers an infinite event.
Describe the bug
useInfiniteScroll v10 behavior is different with v9
Scrolling to the edge triggers an infinite event.
Reproduction
https://github.com/sondh0127/my-vitesse-app-useInfiniteScroll
System Info
System:
OS: macOS 13.3.1
CPU: (10) arm64 Apple M1 Pro
Memory: 59.34 MB / 16.00 GB
Shell: 5.9 - /bin/zsh
Binaries:
Node: 18.13.0 - ~/Library/Caches/fnm_multishells/94889_1682258323298/bin/node
Yarn: 1.22.19 - ~/Library/Caches/fnm_multishells/94889_1682258323298/bin/yarn
npm: 8.19.3 - ~/Library/Caches/fnm_multishells/94889_1682258323298/bin/npm
Browsers:
Brave Browser: 112.1.50.121
Chrome: 112.0.5615.137
Safari: 16.4
npmPackages:
@vueuse/core: 10.1.0 => 10.1.0
@vueuse/head: ^1.1.26 => 1.1.26
vue: ^3.2.47 => 3.2.47
Used Package Manager
pnpm
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.
About this issue
- Original URL
- State: closed
- Created a year ago
- Reactions: 2
- Comments: 16 (7 by maintainers)
Commits related to this issue
- fix(useInfiniteScroll)!: improve loading strategies, close #1701, close #1685 — committed to vueuse/vueuse by antfu a year ago
- reproduce #3019 — committed to scottbedard/vueuse by scottbedard a year ago
I’m seeing this issue as well, see repro here
Going to look into this and see if I can find the problem
Update: This appears to be caused by
arrivedState[direction]never being flipped back tofalse, which leads to the infinite loop. The reason it’s never being set tofalseis because the handler to do that is only bound to ascrollevent, which is not fired when the dom resizes.https://github.com/vueuse/vueuse/blob/81bcaa9d99bece266bc4351af3aa5147eda0020b/packages/core/useScroll/index.ts#L163-L223
You’ll notice that any scrolling in the container stops the cycle. I think we have a couple options for fixing this, I’ll play with them a bit and post my findings…
Update 2: Here is a potential fix, let me know if this helps you guys! https://github.com/vueuse/vueuse/pull/3030
@antfu we can close this
@sondh0127 @JJBocanegra it’s because the version of vueuse you are using is not the latest. The latest vueuse/core does not have this problem:
the old version which has problem:
you can check the @vueuse/core in your node_modules
@scottbedard I’m wondering if it’s expected that when we reach the end (i.e. nothing else to load), the
onLoadMore()handler is (still) called infinitely every 100ms?