richardscarrott / jquery-ui-carousel

jQuery RS Carousel is a responsive and touch-enabled carousel written on top of jQuery and the jQuery UI Widget Factory providing a full and familiar API in less than 2.6kB minified and gzipped.
http://richardscarrott.github.io/jquery-ui-carousel/
192 stars 56 forks source link

Getting the index of the current page #17

Closed lucio11 closed 12 years ago

lucio11 commented 12 years ago

Hi there,

I'm trying to build a 3-carousels-cascade, and controlling them with just one set of Pagination Links.. As you suggested I'm using something similar to $('.slave-carousel').carousel('goToPage', XXXXXXX);

..but I'm really struggling about recognizing the index of the current page on the Master Carousel, as to set the Slaves Carousel at the same page...

any idea ?

lucio11 commented 12 years ago

Well, I guess I solved it in this way:

$(document).ready(function() {

var myCarousel1 = $('#rs-carousel');
var myCarousel2 = $('#slave1-carousel');
var myCarousel3 = $('#slave2-carousel');

var currentPage = null;

myCarousel1.carousel({
    pagination: true,
    insertPagination: true,
    afterAnimate: function () {
        currentPage = myCarousel1.carousel('getPage');
        myCarousel2.carousel('goToPage', currentPage, true);
    }
});

myCarousel2.carousel({
    pagination: false,
    afterAnimate: function () {
        myCarousel3.carousel('goToPage', currentPage, true);
    }
});

myCarousel3.carousel({
    pagination: false
});

});

richardscarrott commented 12 years ago

Yeah, I need to update the docs as last night I reduced the data sent to callback events and made a number of methods public instead but looks like you found your way.