Skip to content

Commit

Permalink
Render a placeholder div for omitted items
Browse files Browse the repository at this point in the history
  • Loading branch information
Mikko Matilainen authored and xiaolin committed Jan 22, 2017
1 parent 91c6afb commit 4c2156c
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/ImageGallery.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -773,25 +773,23 @@ export default class ImageGallery extends React.Component {
const renderItem = item.renderItem ||
this.props.renderItem || this._renderItem.bind(this);

const showItem = !this.props.lazyLoad || alignment || this._lazyLoaded[index];
if (showItem && this.props.lazyLoad) {
this._lazyLoaded[index] = true;
}

const slide = (
<div
key={index}
className={'image-gallery-slide' + alignment + originalClass}
style={Object.assign(this._getSlideStyle(index), this.state.style)}
onClick={this.props.onClick}
>
{renderItem(item)}
{showItem ? renderItem(item) : <div style={{ height: '100%' }}></div>}
</div>
);

if (this.props.lazyLoad) {
if (alignment || this._lazyLoaded[index]) {
slides.push(slide);
this._lazyLoaded[index] = true;
}
} else {
slides.push(slide);
}
slides.push(slide);

let onThumbnailError = this._handleImageError;
if (this.props.onThumbnailError) {
Expand Down

0 comments on commit 4c2156c

Please sign in to comment.