PDA

View Full Version : Get Active index of a carousel



dbottillo
29 Jul 2010, 1:37 AM
Hi,

how can i get the active index of a carousel?
in documentation i found getActiveItem() method for carousel but in javascript return an object
i try to access to page of activeItem in documentation but i found 'page not found'

i also try carousel.getActiveItem().index but it return undefined

Thank you

Daniele

meyerovb
29 Jul 2010, 4:54 PM
Carousel being rewritte for 93, if this is still broke after that, add a post to the bugs forum

TommyMaintz
29 Jul 2010, 5:27 PM
I have added a method to the .93 branch called getActiveIndex. In the meantime, I can show you the code for the implementation of that method.



/**
* Returns the index of the currently active card.
* @return {Number} The index of the currently active card.
*/
getActiveIndex : function() {
return this.items.indexOf(this.layout.activeItem);
}


This translates to



carousel.items.indexOf(carousel.layout.activeItem);
// or the following (which I dont use in getActiveIndex since it adds an additional function call)
carousel.items.indexOf(carousel.getActiveItem());

meyerovb
29 Jul 2010, 9:19 PM
Tommey, just to clarify, this method was added to any card layout component, or just to carousel?

dbottillo
30 Jul 2010, 12:46 AM
ok thank you
it works! ;)