2
votes

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

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

  • On page load no slide
  • Press 'Play' button, side with interval 10000
  • Press 'Pause' button and pause
  • rinse and repeat Play & Pause

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.

1
What effect are you currently getting? Can you illustrate with a bootply? - Ranveer

1 Answers

2
votes

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