diff --git a/packages/react-ui-core/src/Carousel/PhotoCarousel.js b/packages/react-ui-core/src/Carousel/PhotoCarousel.js index 5a8b49a01..90b87873b 100644 --- a/packages/react-ui-core/src/Carousel/PhotoCarousel.js +++ b/packages/react-ui-core/src/Carousel/PhotoCarousel.js @@ -30,11 +30,15 @@ export default class PhotoCarousel extends PureComponent { static defaultProps = { lazyLoad: false, - lazyLoadGallery: false, + disableLazyLoadGallery: false, isBackgroundImage: false, theme: {}, } + get shouldLazyLoadGallery() { + return !this.props.disableLazyLoadGallery && this.props.lazyLoad + } + photo(item) { const { server } = this.props const { @@ -47,8 +51,8 @@ export default class PhotoCarousel extends PureComponent { } lazyLoadGallery() { - const { lazyLoadGallery } = this.props - const props = typeof lazyLoadGallery === 'object' ? lazyLoadGallery : {} + const { shouldLazyLoadGallery } = this + const props = typeof shouldLazyLoadGallery === 'object' ? shouldLazyLoadGallery : {} return ( { theme={theme} items={items} server="https://rentpath-res.cloudinary.com/" - lazyLoadGallery={{ once: true, height: 400, width: 300, offset: 200 }} + lazyLoad={{ once: true, height: 400, width: 300, offset: 200 }} + /> + ) + expect(wrapper.find(LazyLoad).length).toBeTruthy() + }) + it('doesnt lazyload gallery if disabled', () => { + const wrapper = shallow( + ) expect(wrapper.find(LazyLoad).length).toBeTruthy()