Last active
December 30, 2018 22:00
-
-
Save andrisgauracs/d1d1c5bffadc7728535a80d10ff01389 to your computer and use it in GitHub Desktop.
An image wrapper component, that holds all of our data inside it, plus it get triggered to run only when scrolled into view
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* an image wrapper component, that holds | |
| all of our data inside it, plus it | |
| get triggered to run only when scrolled into view. */ | |
| const ImageWrapper = ({ image, nr, render }) => ( | |
| render ? | |
| <ImageContainer> | |
| <Suspense fallback={ | |
| <ImageContainer> {/* This gets shown while the full res image is preloading */} | |
| <img className="blurry" src={image.small} alt={`img_small_${nr}`}/> | |
| {/* This gets shown below while the low res image is preloading */} | |
| <Style.Loader>{'Loading...'}</Style.Loader> | |
| </ImageContainer> | |
| }> | |
| <ImageContainer> | |
| {/* This gets shown when the full res image is finally loaded */} | |
| <Img src={image.large} alt={`img_large_${nr}`}/> | |
| </ImageContainer> | |
| </Suspense> | |
| </ImageContainer> | |
| : | |
| <ImageContainer/> | |
| ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment