How to get current slide and total slides in Featherlight lightbox?

1k views Asked by At

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?

1

There are 1 answers

0
Marc-André Lafortune On

Correct, currentNavigation() will return the index of the current slide.

It does this by calling slides() (just renamed from images(), this question made me realize that it was not the best name), so you can use slides().length to get the number of slides.