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

Calling another smooth scroll before previous smooth scroll completes causes strange behavior #221

Closed
aeharding opened this issue Oct 24, 2023 · 7 comments · Fixed by #222
Assignees

Comments

@aeharding
Copy link
Sponsor Contributor

Hello! Thank you for the smooth scrolling support. It works very well, with the only following bug I've found.

Describe the bug

Calling another smooth scroll before previous smooth scroll completes causes strange behavior

To Reproduce

Call virtuaRef.scrollToIndex(1, { smooth: true });, then before smooth scroll is complete, virtuaRef.scrollToIndex(2, { smooth: true }); then virtuaRef.scrollToIndex(3, { smooth: true });

Observe once it scrolls to the third item, smooth scrolling goes back to the second item. It's like there is some strange queuing logic happening that's not being cancelled.

Expected behavior

User calling scrollToIndex should cancel any previous smooth scroll

Platform:

  • OS: MacOS
  • Browser: Firefox
  • Version of react: 18.2.0
  • Version of this package: 0.15.0
@inokawa
Copy link
Owner

inokawa commented Oct 25, 2023

Could you try 0.15.1? Thank you for reporting it!.

@aeharding
Copy link
Sponsor Contributor Author

Could you try 0.15.1? Thank you for reporting it!.

Yes this appears to be resolved! However, is it just me, or is there a short 200ms-ish delay on starting a smooth scroll? It makes pressing the scroll button feel a bit laggy in my test. I can make a new issue if that helps.

@inokawa
Copy link
Owner

inokawa commented Oct 25, 2023

It's intended one but there may be room for improvement.

Destination of browser's native smooth scrolling can't be changed during scrolling. So what we can do is measuring all items before scrolling, or scrolling several times like react-virtuoso, (or implement easing with requestAnimationFrame by ourself). Now the first one implemented.

I'm thinking now is cutting down the measurement lags as much as possible and skip some measurements for already measured items, .

@aeharding
Copy link
Sponsor Contributor Author

I see! For what its worth, this lag doesn't seem to be present in 0.15.0.

@inokawa
Copy link
Owner

inokawa commented Oct 25, 2023

@aeharding
I hope it was resolved in 0.15.3.
Thank you for your helpful feedback!

@aeharding
Copy link
Sponsor Contributor Author

Thanks! The responsiveness is fixed :)

I am only experiencing one other issue. This is where I scroll very far down my feed. Then, when I tap to go to the top, the first tap doesn't work. The following tap works.

In this case, I'm always scrolling to the top of the page, index = 0 if it helps for optimization purposes :)

Let me know if you would like a separate issue for this.

@inokawa
Copy link
Owner

inokawa commented Oct 26, 2023

Could you raise another issue please? I may not understand the situation correctly.

You said calling scrollToIndex should cancel any previous smooth scroll but should it be changed in some case? Thanks.

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 a pull request may close this issue.

2 participants