jonasgeiler / svelte-tiny-virtual-list

📚 A tiny but mighty list virtualization library for Svelte, with zero dependencies 💪 Supports variable heights/widths, sticky items, scrolling to index, and more!
https://svelte-tiny-virtual-list.jonasgeiler.com
MIT License
467 stars 25 forks source link

Issue with scrolling getting stuck in infinite loop #53

Open GimpMaster opened 5 months ago

GimpMaster commented 5 months ago

I just gave this a quick try. I have 80 items all with height of 733px. When I scroll down to item number 10, the scroll but starts studdering all over the place and gets into a lock state, CPU goes crazy high. Items are being added/removed infinitly. Have you seen this?

<VirtualList width={'560px'} height={Number($globalFeedRef?.getBoundingClientRect().height)} itemCount={80} itemSize={733}

{index}

jonasgeiler commented 5 months ago

I have noticed this problem myself while working on the new website. There is actually a infinite loop detection but it doesn't seem to work sometimes... I will look into this but for now the only advice I can give you is making sure the container of the infinite list has a fixed height and maybe try using flexbox around the virtual list. I unfortunately don't remember what exactly fixed my infinite growing problem while working on the new website, but maybeee the code will help: https://github.com/jonasgeiler/svelte-tiny-virtual-list/blob/49ff096cd0a53deedab268cd090cc5f5c2ab0c2c/src/routes/demos/hacker-news/%2Bpage.svelte#L72

If your problem still persists it would be great if you could recreate it in a REPL and I will look into it further: https://svelte.dev/repl