Skip to content
This repository has been archived by the owner on Jan 19, 2023. It is now read-only.

Commit

Permalink
feat: onImageLoad API
Browse files Browse the repository at this point in the history
  • Loading branch information
fritz-c committed Mar 8, 2018
1 parent 70a1ad6 commit b08be00
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ nextSrcThumbnail | string | | | Thumbnail image url c
onCloseRequest | func | | yes | Close window event. Should change the parent state such that the lightbox is not rendered
onMovePrevRequest | func | empty function | | Move to previous image event. Should change the parent state such that `props.prevSrc` becomes `props.mainSrc`, `props.mainSrc` becomes `props.nextSrc`, etc.
onMoveNextRequest | func | empty function | | Move to next image event. Should change the parent state such that `props.nextSrc` becomes `props.mainSrc`, `props.mainSrc` becomes `props.prevSrc`, etc.
onImageLoad | func | empty function | | Called when an image loads.<div>`(imageSrc: string, srcType: string, image: object): void`</div>
onImageLoadError | func | empty function | | Called when an image fails to load.<div>`(imageSrc: string, srcType: string, errorEvent: object): void`</div>
imageLoadErrorMessage | node | `"This image failed to load"` || What is rendered in place of an image if it fails to load. Centered in the lightbox viewport.
onAfterOpen | func | empty function | | Called after the modal has rendered.
Expand Down
4 changes: 2 additions & 2 deletions src/react-image-lightbox.js
Original file line number Diff line number Diff line change
Expand Up @@ -1160,7 +1160,7 @@ class ReactImageLightbox extends Component {
};

inMemoryImage.onload = () => {
this.props.onImageLoad(imageSrc, srcType);
this.props.onImageLoad(imageSrc, srcType, inMemoryImage);

this.imageCache[imageSrc] = {
loaded: true,
Expand Down Expand Up @@ -1725,7 +1725,7 @@ ReactImageLightbox.propTypes = {
// (imageSrc: string, srcType: string, errorEvent: object): void
onImageLoadError: PropTypes.func,

//PB: Called when image successfully loads
// Called when image successfully loads
onImageLoad: PropTypes.func,

// Open window event
Expand Down

0 comments on commit b08be00

Please sign in to comment.