rintoj / ngx-virtual-scroller

Virtual Scroll displays a virtual, "infinite" list.
https://rintoj.github.io/ngx-virtual-scroller
MIT License
977 stars 294 forks source link

Let user provides a method to determine width/height of an item #288

Open chabb opened 5 years ago

chabb commented 5 years ago

Can we provide to client code a callback that will allow developer to pass the height/width of the children, that will allow doing call .getBoundingClientRect()... those are costly call as they trigger a layout ?

I give you an example, i know that my cells have either 50/100/150 px of height, so i could use this fact to avoid doing call to .getBoundingClientRect().. which will make thing faster ( chrome profiler says it does 0.13 ms, but then there are some layout/painting that seems to be triggered by this call )

speige commented 5 years ago

This is a good idea. Would you mind attempting to code this & submitting a pull request? Shouldn't be too difficult. I can help you if you get stuck. Thanks.

chabb commented 5 years ago

This should not be too complicated. But then we should add some documentation around it and add and an example. I'll try to come with that.