Mark
Mark

Reputation: 630

Bootstrap Carousel - Load | Play | Pause

I've spent some time and this one evades me.

What I'd like to do with the Carousel ...

In js I'm using

// Play | Pause for carousel
$('#myCarousel').carousel({

});

$('#playButton').click(function () {
    $('#myCarousel').carousel('cycle');
});

$('#pauseButton').click(function () {
    $('#myCarousel').carousel('pause');
});

... but I'm just unable to get the proper effect as described. If I set the interval at the initial load it will kick off.

Upvotes: 2

Views: 2689

Answers (1)

Carol Skelly
Carol Skelly

Reputation: 362390

The carousel should be initialized with no interval (false). Then, set the interval when the "Play" btn is clicked. Try this...

$('#myCarousel').carousel({
  interval:false
});

$('#btnPause').click(function() {
  $('#myCarousel').carousel('pause');
});

$('#btnPlay').click(function() {
  $('#myCarousel').data('bs.carousel').options.interval=1000;
  $('#myCarousel').carousel('cycle');
});

Demo: http://bootply.com/113413

Upvotes: 2

Related Questions