Page 2 of 2

Control the number of carousel frames displayed

Posted: Tue Aug 19, 2014 10:33 pm
by Yurii Orishchuk

Hi Hawk,

Here is code for case you've described:

pre

//You can adjust items to show here.
var itemsToShow = 3;

//Note: you need replace "mobilecarousel_2" with your carousel component.
var carousel = jQuery('[name="mobilecarousel_2"]');

if(!self.carouselView){
self.carouselView = carousel.find(".ui-carousel-items").html();
self.carouselIndicators = carousel.find(".ui-carousel-indicators").html();
};

carousel.find(".ui-carousel-items").html(self.carouselView);
carousel.find(".ui-carousel-indicators").html(self.carouselIndicators);

carousel.carousel("refresh");

var framesCount = carousel.carousel("length");

//Remove frames loop. You can adjust it in accordance with your needs.
for(var i = framesCount - 1; i itemsToShow - 1; i--)
carousel.carousel("remove", i);

/pre

Note: this code save in self.carouselView and self.carouselIndicators variables original frames so if your frames will be changed you need to delete these values.

Regards.