malsup / cycle2

2nd gen cycling
899 stars 236 forks source link

Slideshow with carousel pager not working #317

Open pigmeu opened 10 years ago

pigmeu commented 10 years ago

The pager is built using "Advanced Custom Template" on a carousel slideshow.

Strange behaviour when clicking pager. Doesn't show correct slide in main slideshow then stops working altogether.

See it here: http://jsfiddle.net/Shmfv/1/

pigmeu commented 10 years ago

Finally figured out a workaround... Can't use the plugin's pager option and had to add some scripting.

// fill the pager

$('.boxGaleria > div').clone().appendTo('.boxNav');

// update active slide in both slideshows

var slideshows = $('.cycle-slideshow').on('cycle-update-view',function(event, opts) {
    slideshows.not(this).cycle('goto', opts.currSlide);
});

// add click to the carousel/pager, correct slide index because the carousel adds a few duplicate children before and after to display correctly

$('.boxNav div').click(function(){
    var index = $('.boxNav').data('cycle.API').getSlideIndex(this);
    var todos = $('.boxGaleria').data('cycle.opts').slideCount;
    slideshows.cycle('goto', (index-todos));
});