nuka-carousel
nuka-carousel copied to clipboard
Enhancement: Lazy loading for images.
It would be nice if lazy loading is implemented for images
:+1:
shameless advertizing You can use react-lazy to achieve this so the carousel component doesn't need to become more complex than it already is. /shameless advertizing
@Merri Unless I'm missing something, react-lazy doesn't seem to help. On my quick test all the images loaded before I started scrolling the gallery, both for a full page width gallery and for smaller galleries
using something like this
<Carousel>
<Lazy cushion={100}>
<img src={getUrl('imagesUrl') + this.state.data.images[0]}/>
</Lazy>
</Carousel>
The use case would be images don't load until the slide is scrolled to (or even better, the slide before)
When I have a lot of galleries on one page, it works in so far as all the slides for a gallery load as soon as it is visible, but images are not loaded for slides that are not yet visible.
@david-owens-akqa Right now it still lacks the feature of finding the proper nearest parent element of true visibility. So the full visible viewport works as a comparison point. This works great for mobile, but if you test on 2560 x 1440 full screen browser and have only a couple of images then yes, all of them get loaded immediately.
I've been a bit on the lazy side in adding features.
Pun intended.
Any update on this?
@Merri React - lazy doesn't seem to help.
@kenwheeler Any updates?
+1
+1
+1
Hello
I want to show you my workaround to handle lazy loading.
Explanations are in the comments.
https://gist.github.com/lauterry/cd3cef520644b1413471d5841645c597
Best regards
Has anyone implemented this?
Works with react-lazy-images... Example https://codesandbox.io/s/m4kzo330vp?from-embed
HTML-native lazy loading works: https://codesandbox.io/s/kind-noether-gz172v