WICG / virtual-scroller

Other
2k stars 83 forks source link

Default create/update/recycleElement #86

Closed valdrinkoshi closed 6 years ago

valdrinkoshi commented 6 years ago

Fixes #80. With these new defaults, the user only needs to set updateElement to effectively customize the rendering. virtual-scroller creates a <div> as a child template, but this can be customized by distributing a <template> with any element into the scroller. The scroller will recycle these children by default.

Updated README.md and couple demos as an example of usage.

domenic commented 6 years ago

I pushed more readme updates. One thing I was thinking is that resetting recycleElement should not reset createElement. It would be nice to be able to turn off recycling while still getting default element creation. What do you think?

valdrinkoshi commented 6 years ago

Uhm, yeah that should be possible. So:

domenic commented 6 years ago

Yep, that sounds perfect to me.

valdrinkoshi commented 6 years ago

Done 👌 There is a chance for this to be a shotgun for the user, for example if the user sets recycleElement !== null while keeping the default createElement, they'll be effectively keeping those elements in the dom while creating new elements. But I feel like that's an edge case, I expect the user to set createElement and recycleElement within the same RAF.