react-tiny-virtual-list icon indicating copy to clipboard operation
react-tiny-virtual-list copied to clipboard

Suggestion: change padding-top & padding-bottom of the container

Open felixmosh opened this issue 6 years ago • 6 comments

Hi,

I've investigated how virtuallization of Instagram works and saw that they are not using position: absolute at the children & not updating children positioning / styles at all, instead they changing padding-top & padding-bottom of the parent container! (SUPER COOOL 🤩).

WSdq465kVC

WDYT? can we refactor this lib to something similar?

felixmosh avatar Nov 28 '19 09:11 felixmosh

This is do-able, but I'm not clear on what the benefits would be. Have you tested the performance of this approach over the current approach?

clauderic avatar Nov 28 '19 14:11 clauderic

The benefit is that you are not using absolute positioning on the items, that means that the items will have native flow inside the container.

felixmosh avatar Nov 28 '19 15:11 felixmosh

You still need to provide exact height measurements for every single item, and you won't be able to use margin between the items, so I'm still not sure I see a clear benefit

clauderic avatar Nov 28 '19 15:11 clauderic

There is margin between items in Insta & as you see there is no explicit height on the container but it derived, so there is a possibility to allow overflow... And it still work!

Additional benefite of native flow is the support for RTL in horizontal list for free.

felixmosh avatar Nov 28 '19 15:11 felixmosh

Think of it, it not requires overflow: hidden & height on the wrapper, no need for position:absolute + height on each item...

felixmosh avatar Nov 29 '19 08:11 felixmosh

I see that twitter are doing the same thing image

felixmosh avatar Dec 07 '19 20:12 felixmosh