Skip to content
This repository was archived by the owner on Jun 6, 2025. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions packages/react-ui-core/src/Carousel/PhotoCarousel.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 (
<LazyLoad
Expand Down Expand Up @@ -78,7 +82,7 @@ export default class PhotoCarousel extends PureComponent {
className,
theme,
items,
lazyLoadGallery,
disableLazyLoadGallery,
...rest
} = this.props

Expand All @@ -100,15 +104,15 @@ export default class PhotoCarousel extends PureComponent {
const {
theme,
items,
lazyLoadGallery,
} = this.props
const { shouldLazyLoadGallery } = this

if (!items || !items.length) {
return (
<div className={theme['PhotoCarousel-empty']} />
)
}

return lazyLoadGallery ? this.lazyLoadGallery() : this.renderCarousel()
return shouldLazyLoadGallery ? this.lazyLoadGallery() : this.renderCarousel()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,19 @@ describe('PhotoCarousel', () => {
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(
<PhotoCarousel
theme={theme}
items={items}
server="https://rentpath-res.cloudinary.com/"
lazyLoad={{ once: true, height: 400, width: 300, offset: 200 }}
disableLazyLoadGallery
/>
)
expect(wrapper.find(LazyLoad).length).toBeTruthy()
Expand Down