In a simple featherlight gallery, how does one get the current slide
and total slides
?
Demo: http://noelboss.github.io/featherlight/gallery.html
I am retrieving the featherlight
object with $.featherlight.current()
but am not sure how to proceed.
edit:
I've been able to find the total slides, though not exactly ideal, through $.featherlight.current().$source.length
I say not exactly ideal because I believe this may vary depending on the HTML upon which featherlight is instantiated, for my own use I had to traverse the source to the appropriate level before counting
So now I am just not sure of a good way to find the current slide
?
edit2: With the help of someone on their github issue tracker (my mistake, was supposed to post here on SO), looking at the source for navigateTo
, I was able to easily find currentNavigation()
, and thus, the simple answer is $.featherlight.current().currentNavigation()
So then the final question is if there is a better way to find the total slide count?
Correct,
currentNavigation()
will return the index of the current slide.It does this by calling
slides()
(just renamed fromimages()
, this question made me realize that it was not the best name), so you can useslides().length
to get the number of slides.