Issue with prepending items when reverse scrolling in Safari
Describe the bug When I scroll up and new items are prepended while scrolling, it breaks scroll behavior in Safari. Here is the demo https://github.com/inokawa/virtua/assets/37265338/ed93157c-65fa-4bf4-9369-a3535cb44ed9 Right after prepending there are different items visible in viewport, you can slow down the video to see it better.
If I scroll fast I looks like this https://github.com/inokawa/virtua/assets/37265338/78b59e01-ab8b-430d-9457-50a1779d1248
To Reproduce Open "Chat" storybook example in Safari (I only changed page size from 100 to 10)
Expected behavior Scroll position should be adjusted correctly, the same elements should be visible as before prepending
Platform:
- OS: MacOS
- Browser: Safari
- Version of this package: 0.24.0
- Version of framework: react 18.2.0
Additional context Might be related to https://github.com/inokawa/virtua/issues/362
If I modify code like this, it will work fine.
setItems delay and useFirstItemChanged instead of isPrepend.current are important changes. But delay should be significant, even 1000 doesn't always work, so that's not a solution
It looks like some part of the issue is caused by #362.