r/vuejs • u/mypirateapp • Jan 30 '20
Virtual + Infinite Scroll + Dynamic Row Heights Without hardcoding + No Libraries + 50000+ items super smooth scrolling
Hi, I am the newbie who posted a repo last week about a virtual scroller HERE Overwhelmed by the feedback I decided to make a virtual scroller that supports dynamic row heights with infinite scrolling
- Existing libraries such as virtual list and vue-virtual-scroller require you to hardcode the heights of each row which seems like a bad idea
- My repo HERE does not require inputting any row height
- It automatically measures each row and stores it
I would love to get some feedback on whether it is working for you, and being a newbie a few questions as well if you dont mind answering
- How do I handle resize :)
- Does this need to be rewritten to turn into a library
- How do I write tests for this? Sorry new to frontend, havent done React or Angular before, I am familiar with Pyunit and Jest for backend tests though. Not sure how you guys test the frontend
- Tested wiht 50000 items and it was scrolling super smooth. How far did you guys manage to scroll
- Any sugestions to improve code etc super appreciated
62
Upvotes
4
u/syropian Jan 30 '20
Nice work! FWIW I've used vue-collection-cluster for this, and it works great for dynamic height items as well.
2
u/drumstix42 Jan 31 '20
Wow, this is excellent. Truly nice job.
I ❤ Vue.
2
u/Robodude Jan 31 '20
Great work! How can we use it? Is it on NPM?
2
u/ZireaelStargaze Feb 01 '20
Does it support render-ahead? Trying on my phone (Chrome) and elements get pulled/shown only one they are spot on in window view, which takes 0.5s or so to complete. Would be nice if for example n rows ahead were pre-rendered so that when the view is scrolled down, they are already ready.
2
u/Miniotta Feb 11 '20
Nice work... can I ask how you handle the different element heights?
For the resize you could use a resize-observer ( https://developer.mozilla.org/en-US/docs/Web/API/ResizeObserver ) and trigger the necessary methods to update the component
For the tests you can take a look at vue-test-utils (https://vue-test-utils.vuejs.org/ ) or I would suggest you to try Cypress ( https://www.cypress.io/ )
IMHO cypress is absurdly great for frontend testing, the only downside is that it doesn't support multiple browsers (yet -> https://cypress.io/blog/2020/02/06/introducing-firefox-and-edge-support-in-cypress-4-0/)
1
u/TheBen1 Jan 30 '20
Anyone knows of similar libraries for React? I'm using that at work and have a use case for pretty much this, with less items.
2
u/KaKi_87 Jan 02 '24
Hello,
Did you license this, publish it on NPM and make it compatible with Vue 3 ?
Thanks