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
447 stars 24 forks source link

Unnecessary item creation / destruction #29

Closed inzanez closed 1 year ago

inzanez commented 1 year ago

Hi

I have an image viewer that might display thousands of images, and the user can zoom into the images using the mouse-wheel and the 'control' key. I noticed that if the list is large and the current position is not somewhere at the beginning (like the first 100 items? not sure where the limit is), items that are on screen are being rerendered when zooming.

To see what I mean:

https://svelte.dev/repl/69d2cb5333304d29a661c40b2d5808d0?version=4.2.1

If you press 'Ctrl' and scroll while at the beginning of the list, the time of the items do not update. If you scroll down 50% into the list and do the same, the time updates with every "zoom tick". And the time only updates if 'onMount' is called in the rendered Item...why is that? That should not be I think, should it?

inzanez commented 1 year ago

Never mind, my mistake...the await tick(); was actually incorrect.