jQuery Scrollable return to start once end is reached -
i'm attempting newest jquery tools' scrollable return first item once end reached. showing 4 items horizontally, moving 1 item @ time next/previous buttons. there property called 'circular' doesn't take effect until last item in item showing. need stop scrollable once last item reached, scroll first item.
i've tried few things such as:
jquery(function() { // initialize scrollable control jquery(".scrollable").scrollable(); // scrollable control var scrollable = jquery(".scrollable").data("scrollable"); // set number of visible items var size = 4; // handle scrollable control's onseek event scrollable.onseek(function(event, index) { // check see if we're @ end if (this.getindex() >= this.getsize() - size) { // disable next link jquery("a.next").addclass("disabled"); } }); // handle scrollable control's onbeforeseek event scrollable.onbeforeseek(function(event, index) { // check see if we're @ end if (this.getindex() >= this.getsize() - size) { // check see if we're trying move forward if (index > this.getindex()) { // cancel navigation scrollable.seekto(0,1000); } } }); });
again, issue circular isn't starting trigger until there 2 out of 4 empty items showing, populate other two, wondering if possible make smoother , never have empty item showing.
[site removed]
issue fixed reverting jquery tools v1.2.5 v1.2.7
i have used following code detect when reaches end, scroll beginning of item list once end reached.
var $scroller = $('.scrollable').scrollable({onbeforeseek:carousel}).autoscroll().data('scrollable'); $items = $('.scrollable .items div'); function carousel(e, idx) { // set 4 stops after 4 items if(idx > $scroller.getsize() - 4) { // return beginning $scroller.seekto(0).stop(); // stop when reach end return false; } }
Comments
Post a Comment