loktar00 / react-lazy-load

React component that renders children elements when they enter the viewport.
MIT License
979 stars 166 forks source link

remove wrapper height once loaded #115

Open freder opened 6 years ago

freder commented 6 years ago

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?

tzimmermann commented 6 years ago

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',
        },