Skip to content

Commit

Permalink
Fix #216 Cannot read property 'complete' of undefined
Browse files Browse the repository at this point in the history
  • Loading branch information
lkazberova committed Feb 28, 2018
1 parent 3c29954 commit 61d4579
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/Lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ class Lightbox extends Component {

// preload current image
if (this.props.currentImage !== nextProps.currentImage || !this.props.isOpen && nextProps.isOpen) {
const img = this.preloadImage(nextProps.currentImage, this.handleImageLoaded);
const img = this.preloadImageData(nextProps.images[nextProps.currentImage], this.handleImageLoaded);
this.setState({ imageLoaded: img.complete });
}

Expand All @@ -109,10 +109,10 @@ class Lightbox extends Component {
// ==============================

preloadImage (idx, onload) {
const data = this.props.images[idx];

return this.preloadImageData(this.props.images[idx], onload);
}
preloadImageData (data, onload) {
if (!data) return;

const img = new Image();
const sourceSet = normalizeSourceSet(data);

Expand Down

0 comments on commit 61d4579

Please sign in to comment.