react-flickity-component icon indicating copy to clipboard operation
react-flickity-component copied to clipboard

Proper approach for setting a Loading State for flicking slider

Open monecchi opened this issue 5 years ago • 1 comments

I was hoping to create a HOC where I’d hook on Flickity events to set a loading state so that I could display a kind of mock or loading skeleton for the slider while flickity isn’t ready or when images have not loaded yet...

I’ve tried to use the lazyload event in order to check for images and then use useEffect(), useState() to define its loading state, but that seems too late for displaying a loading skeleton...

I also tried to apply a css class to the slides container when images were not yet loaded, but by using lazyload, the images are loaded so fast that the styles which mimic a loading skeleton are quickly removed after lazyload is done...

I’d really appreciate any hints regarding a proper way of achieving that effect...

monecchi avatar Jul 04 '20 17:07 monecchi

I'm afraid currently there is no good way to do this. We have this flickityReady internal state to indicate whether it's ready, but it's not exposed.

Maybe we could add a flickityReadyCallBack option

yaodingyd avatar Jul 14 '20 18:07 yaodingyd