bootstrap icon indicating copy to clipboard operation
bootstrap copied to clipboard

Carousel pills/progress

Open msmeeks opened this issue 14 years ago • 25 comments

It would be nice to have some indication of the total number of items in the carousel and the current position of the carousel.

Many other carousel widgets use pills to display this information.

msmeeks avatar Feb 15 '12 15:02 msmeeks

+1

BenjiZombie avatar Feb 15 '12 18:02 BenjiZombie

+1

(and responsive prev/next buttons would be great too)

Tuckie avatar Feb 16 '12 21:02 Tuckie

+1

simonfranz avatar Feb 17 '12 19:02 simonfranz

+1

chouti avatar Feb 21 '12 05:02 chouti

+1

Anahkiasen avatar Feb 21 '12 08:02 Anahkiasen

+1 Can't remember the last modern slideshow I saw that didn't have the dots for navigation. Ex: http://www.apple.com/macosx/mountain-lion/

TechRemarker avatar Mar 11 '12 16:03 TechRemarker

+1 The demo of www.swipejs.com has this feature too.

ibrent avatar Mar 18 '12 00:03 ibrent

+1

mike avatar Mar 20 '12 00:03 mike

+1

ShaneSheppard avatar Mar 26 '12 13:03 ShaneSheppard

+1

cmanou avatar Apr 14 '12 12:04 cmanou

+1

samme avatar Apr 18 '12 23:04 samme

+!

palpalani avatar Jun 08 '12 10:06 palpalani

+1

Homlean avatar Jun 08 '12 10:06 Homlean

You can do something like this (tnx to nicolas chenet):

var mainSlider = $('#main-slider').carousel().bind('slid', function() { 
    var index = $(this).find(".active").index(); 
    $("#slider-indicator a").removeClass('active').eq(index).addClass('active'); 
});
$("#slider-indicator a").click(function(e){ 
    var index = $(this).index(); 
    mainSlider.carousel(index); 
    e.preventDefault(); 
}); 

And add some code like this (outside the carousel):

<div id="slider-indicator">
    <a class="active">1</a>
    <a>2</a>
    <a>3</a>
</div>  

But a standard implementation would be nice though.

barryvdh avatar Jun 08 '12 11:06 barryvdh

Tagging this issue as popular, please stop commenting on this issue with +1. thanks!

fat avatar Jul 22 '12 20:07 fat

Here's how I got this working. Works exactly like you would expect:

  • carousel rotates automatically
  • bullets increment automatically as carousel rotates
  • bullets are clickable

HTML

<div class="carousel-nav">
    <a href="#" data-to="0" class="active">1</a>
    <a href="#" data-to="1">2</a>
    <a href="#" data-to="2">3</a>
    <a href="#" data-to="3">4</a>
</div>

JS

$('#carousel-screenshots').carousel({
    interval: 5000
});

$(".carousel-nav a").click(function(e){
    e.preventDefault();
    var index = parseInt($(this).attr('data-to'));
    $('#carousel-screenshots').carousel(index);
    var nav = $('.carousel-nav');
    var item = nav.find('a').get(index);
    nav.find('a.active').removeClass('active');
    $(item).addClass('active');
});

$("#carousel-screenshots").bind('slide', function(e) {
    var elements = 4;
    var nav = $('.carousel-nav');
    var index = $('#carousel-screenshots').find('.item.active').index();
    index = (index == elements - 1) ? 0 : index + 1;
    var item = nav.find('a').get(index);
    nav.find('a.active').removeClass('active');
    $(item).addClass('active');
});

CSS The following css should get you started; bullets.png is a sprite with active and inactive states

.carousel-nav a {
  width: 12px;
  height: 12px;
  background: url('../img/bullets.png') no-repeat;
  text-indent: -9999px;
  border: 0;
  float: left;
  margin-left: 5px;
}
.carousel-nav a.active {
  background-position:0 -12px;
}

JonoB avatar Sep 06 '12 15:09 JonoB

Это пиздец... Идите и принесите алкоголь.

bartzitz avatar Oct 20 '12 20:10 bartzitz

+1

ixisio avatar Oct 26 '12 12:10 ixisio

+1

ocodia avatar Nov 16 '12 11:11 ocodia

+1

scotty6435 avatar Nov 23 '12 16:11 scotty6435