react-lazy-load icon indicating copy to clipboard operation
react-lazy-load copied to clipboard

remove wrapper height once loaded

Open freder opened this issue 6 years ago • 1 comments

I'm using the height prop with a roughly estimated value to prevent all items from loading immediately (since their initial height is 0, as long as the images have not been loaded). once an item has loaded, I'd like to remove the height / set it to auto.

it would be nice if the lib provided an option for this. — in the meantime, what would be the easiest way to achieve this?

freder avatar Dec 04 '17 19:12 freder

I agree, it would make sense to unset the height prop once the component is visible (and just let the rendered component take up as much space as it needs). In the meantime, it also works to just set/unset the height via CSS as a workaround. LazyLoad already assigns the required classnames for this (I use JSS syntax):

        '.LazyLoad': {
            height: 100, // or whatever your estimated height might be
        },
        '.LazyLoad.is-visible': {
            height: 'auto',
        },

tzimmermann avatar Jan 02 '18 13:01 tzimmermann