bxSlider short PagerType and maxSlides counting issue -
i'm calling bxslider both pager , min/max slide options.
the issue i'm having it's not counting slides correctly, seems counting current slide (correct) , "next" amount of slides instead of total. how total instead?
https://jsfiddle.net/ulc6qrmn/
html:
<ul class="carousel-slider"> <li><img src="assets/images/cms-images/gallery.jpg" alt=""/></li> <li><img src="assets/images/cms-images/gallery.jpg" alt=""/></li> <li><img src="assets/images/cms-images/gallery.jpg" alt=""/></li> <li><img src="assets/images/cms-images/gallery.jpg" alt=""/></li> <li><img src="assets/images/cms-images/gallery.jpg" alt=""/></li> </ul>
bxslider call:
$('.carousel-slider').bxslider({ auto: false, pager: true, pagertype: 'short', minslides: 3, maxslides: 3, moveslides:1, slidewidth: 800, slidemargin: 40 });
although didn't find issue (atm 333 issues), seems there's bug. provided workaround creates new pager behaves properly. details commented in fiddle , snippet.
snippet
$(function() { var bx = $('.carousel-slider').bxslider({ auto: false, pager: false, //pagertype: 'short', minslides: 3, maxslides: 3, moveslides: 1, /* not required but, useful */ shrinkitems: true, slidewidth: 800, slidemargin: 40, /* callback update active slide index after transition */ onslideafter: counter, /* callback insert new pager element when loading */ onsliderload: init }); function init() { $('.bx-controls').after('<nav id="counter">1 / 5</nav>'); } function counter() { $('#counter').text((bx.getcurrentslide() + 1) + ' / ' + bx.getslidecount()); } });
/* design #counter want */ #counter { margin: 0 auto; text-align: center; font: 400 16px/1.5 verdana; width: 100%; height: 24px; position: relative; top: 2em; color: #9f9f9f; }
<link href="https://cdnjs.cloudflare.com/ajax/libs/bxslider/4.2.5/jquery.bxslider.min.css" rel="stylesheet"> <ul class="carousel-slider"> <li> <img src="http://placehold.it/800x500?text=1"> </li> <li> <img src="http://placehold.it/800x500?text=2"> </li> <li> <img src="http://placehold.it/800x500?text=3"> </li> <li> <img src="http://placehold.it/800x500?text=4"> </li> <li> <img src="http://placehold.it/800x500?text=5"> </li> </ul> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/1.11.3/jquery.min.js'></script> <script src='https://cdnjs.cloudflare.com/ajax/libs/bxslider/4.2.5/jquery.bxslider.min.js'></script>
Comments
Post a Comment