jquery - jCarousel arrow disable if there are no more image in the left or right -
i use sorgalla jcarousel. lets have 9 images , script set scroll: 3, , watching image 1-3, arrow should on right side, means can browse more pics right. then, when browse the right , watching f.e. image 4,5,6, in case arrows should on boths sides, because there pics left , right. but, if browse again right , until image 7,8,9, the arrow on right side should disappear because there nothing more browse right. left arrow should shown in case.
my script:
jquery(document).ready(function($) {
mycarousel = null; // carousel object function mycarousel_initcallback(carousel, state) { if (state == 'init') { mycarousel = carousel; } $('#arrows_gallery_next').bind('click', function() { carousel.next(); return false; }); $('#arrows_gallery_prev').bind('click', function() { carousel.prev(); return false; }); $('.product-view .product-img-box .more-views .jcarousel-skin-tango .jcarousel-item').width(<?php echo $thumbx;?>); }; jquery('#arrows_gallery_carousel').jcarousel({ scroll: 1, visible:3, initcallback: mycarousel_initcallback, buttonnexthtml: null, buttonprevhtml: null, setupcallback:function(){ jquery('#arrows_gallery_carousel.jcarousel-list li').each(function(){ jquery(this).width(103) }) }, }); });
change paging handlers keep track of page number , enable / disable paging buttons once reach start or end.
function mycarousel_initcallback(carousel, state) { var page = 1; $('#arrows_gallery_prev').css('visibility', 'hidden'); if (state == 'init') { mycarousel = carousel; } $('#arrows_gallery_next').bind('click', function() { carousel.next(); page++; $('#arrows_gallery_prev').css('visibility', 'visible'); $('#arrows_gallery_next').css('visibility', (page == 3) ? 'hidden' : 'visible'); return false; }); $('#arrows_gallery_prev').bind('click', function() { carousel.prev(); page--; $('#arrows_gallery_next').css('visibility', 'visible'); $('#arrows_gallery_prev').css('visibility', (page == 1) ? 'hidden' : 'visible'); return false; }); $('.product-view .product-img-box .more-views .jcarousel-skin-tango .jcarousel-item').width(<?php echo $thumbx;?>); };
by way, mentioned scroll set 3, configuration has scroll 1.
Comments
Post a Comment