Skip to content

Commit

Permalink
fix(gatsby-image): use the cache to tell if the image was already loa…
Browse files Browse the repository at this point in the history
…ded (#11303)
  • Loading branch information
CarlRosell authored and pieh committed Jan 28, 2019
1 parent 2ddb20c commit 1d5ccff
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions packages/gatsby-image/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -189,14 +189,15 @@ class Image extends React.Component {
handleRef(ref) {
if (this.state.IOSupported && ref) {
listenToIntersections(ref, () => {
const imageInCache = inImageCache(this.props)
if (
!this.state.isVisible &&
typeof this.props.onStartLoad === `function`
) {
this.props.onStartLoad({ wasCached: inImageCache(this.props) })
this.props.onStartLoad({ wasCached: imageInCache })
}

this.setState({ isVisible: true, imgLoaded: false })
this.setState({ isVisible: true, imgLoaded: imageInCache })
})
}
}
Expand Down

0 comments on commit 1d5ccff

Please sign in to comment.