Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Variable Slide Timeout with jQuery Cycle 2

I'm trying to setup a slideshow to use data attributes for setting the timeout on each slide. This works for jQuery Cycle, but not for jQuery Cycle 2. I think I might be using the wrong function, but didn't find anything similar in the Cycle 2 docs?

HTML:

<div id="slides">
    <img src="img1.jpg" data-duration="1000" />
    <img src="img2.jpg" data-duration="2000" />
    <img src="img3.jpg" data-duration="3000" />
</div>

JS:

$('#slides').cycle({
    fx: 'fadeout',
    speed: 250,
    timeoutFn: function(currElement, nextElement, opts, isForward) { 
        return parseInt($(currElement).attr('data-duration'), 10);
    }
});
like image 702
Siebird Avatar asked Mar 07 '13 13:03

Siebird


1 Answers

Cycle2 supports that directly. Use data-cycle-timeout attributes on the slides instead of data-duration.

like image 93
malsup Avatar answered Sep 17 '22 23:09

malsup