Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Twitter Bootstrap Carousel - Do not cycle

Is there a way to initialize a Twitter Bootstrap Carousel without an automatic cycle? Setting interval: false does not cycle initially but once you click on next or prev, it starts cycling again. I don't want it to cycle at all.

Edit

Here is the jquery code that I'm using to initialize it:

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

To display an image in the carousel:

image_tag('image.png', :'data-target' => '#carousel', :'data-slide-to' => 1)
like image 420
Artem Kalinchuk Avatar asked Oct 20 '13 13:10

Artem Kalinchuk


3 Answers

You can stop Bootstrap's carousel from cycling on page load by adding data-interval="false" to your .carousel div markup. (I wasn't able to get either of the above answers to work.)

like image 187
rda3000 Avatar answered Nov 08 '22 02:11

rda3000


I think you are looking for the "data-wrap" parameter

<div id="crsl1" class="carousel slide" data-ride="carousel" data-wrap="false">
  ...
</div>
like image 36
glampr Avatar answered Nov 08 '22 01:11

glampr


$(document).ready(function() {      
   $('#carousel').carousel('pause');
});

or if that still doesn't do it, try this:

$('#carousel').carousel({interval: false});
$(document).on('mouseleave', '#carousel', function() {
    $(this).carousel('pause');
});

to reset the pause on mouseleave event.

like image 40
E.J. Brennan Avatar answered Nov 08 '22 02:11

E.J. Brennan