I am attempting to get the index of the current item in a JCarousel so that I can display the current position within the Carousel to the user. For example, '13/20'.
How can I do this?
EDIT:
Sample of the end product:
I am attempting to get the index of the current item in a JCarousel so that I can display the current position within the Carousel to the user. For example, '13/20'.
How can I do this?
EDIT:
Sample of the end product:
I think what you are looking for is carousel.first, which will give you the index of the first visible element (there is also carousel.last to show the last visible element).
Here is an example of it's use, based on the simple carousel example with the addition of the carousel.first variable and itemLoadCallback event:
If you have pagination (bullets)
you can simply use:
jcarousel is adding class 'active' to active bullet, if you have numbers on the bullets you just retrieve them by .html() method
Also you can turn them to integers by parseInt:
You can hook into the 'jcarousel:animate' event, and grab the current slide as a jQuery Object.
It doesn't seem as obvious as I would have hoped from a jQuery plugin to be honest. There are two callbacks
itemVisibleInCallback
anditemVisibleOutCallback
, but they're only going to be useful if you're only displaying one image at a time.To be honest, as much as I hate to send you down a totally different path, I would highly recommend using the cycle plugin for carousel work as it allows much, much finer customisation that would I could see from my quick look through the jCarousel (sorry jCarousel author - the code itself looks brilliant!).
Another solution getting the current index of the item with jquery...