Observing image change in autoplay slideshow carousel #197
-
So I want to have an inline slideshow and underneath this slideshow I want to show corresponding captions. However as the slideshow is autoplay I'm not sure the best way to watch for the slide changes on the carousel. I tried to use a ref on the lightbox controller and slideshow as below but neither tracks the image change for me to update the index to show the correct slide caption.
|
Beta Was this translation helpful? Give feedback.
Answered by
igordanchenko
Oct 11, 2023
Replies: 1 comment 2 replies
-
You can use the const [index, setIndex] = React.useState(0);
// ...
<Lightbox
index={index}
on={{ view: ({ index: currentIndex }) => setIndex(currentIndex) }}
// ...
/> |
Beta Was this translation helpful? Give feedback.
2 replies
Answer selected by
hus-o
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You can use the
on.view
callback to keep track of the slide index.