how can add after, before call function in new jquery cycle , links here http://jquery.malsup.com/cycle2
i work jquery cycle(old version) dont know how implement cycle2(new version)
examples jquery code of old version cycle (check after function code )
$('#myslideshow').cycle({ fx: 'scrollhorz', after: function() { $('ul li').removeclass('test'); $(this).addclass('test') } }); <ul id="myslideshow" class="cycle-slideshow" data-cycle-fx="scrollhorz" data-cycle-slides="li" data-cycle-timeout="0" data-cycle-prev=".prev" data-cycle-next=".next"> <li><img src="http://placehold.it/350x150" alt=""></li> <li><img src="http://placehold.it/350x150" alt=""></li> </ul> <a href=# class="prev">prev</a> <a href=# class="next">next</a> </ul>
cycle2 different cycle if read faq bit on website. in cycle2 after
function being not used anymore. if add following line code should work:
$('#myslideshow').on('cycle-after',function(e, optionhash, outgoingslideel, incomingslideel, forwardflag){ $('ul li').removeclass('test'); $(incomingslideel).addclass('test') });
you can remove
after: function() { $('ul li').removeclass('test'); $(this).addclass('test') }
also, cycle2 works without adding $('#myslideshow').cycle({ .. })
bit.
so can have
$('#myslideshow').on('cycle-after',function(e, optionhash, outgoingslideel, incomingslideel, forwardflag){ $('ul li').removeclass('test'); $(incomingslideel).addclass('test') });
and should work. http://jsfiddle.net/3vjgj/12/
Comments
Post a Comment