Variable timeout using jQuery 2 loop

I am trying to set up a slide show to use data attributes to set a timeout on each slide. This works for the jQuery cycle, but not for jQuery Cycle 2 . I think I can use the wrong function, but didn't find anything similar in the docs of cycle 2?

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);
    }
});
+5
source share
1 answer

Cycle2 supports this directly. Use attributes data-cycle-timeouton slides instead data-duration.

+8
source

All Articles