I have three carousel sliders on the single page and I want them to move two of them at the same time .i.e. both should change slider images at the same time. Both have same number of images/slides. Here is the code I am using:
jQuery('#carousel-example-generic1, #carousel-example-generic2').carousel({
interval: 4000
});
And also I tried this code below:
jQuery('.carousel').carousel({
pause:'false'
});
jQuery('#carousel-example-generic1').on('slide', function(){
jQuery('#carousel-example-generic2').carousel('next');
});
But left and right sliders have very little delay in changing slides. And this delay goes on increasing. Any known issues with this kind of problem? Link to the site is this.
JSFiddle: Link
To insert multiple jQuery carousels to the same webpage, you need to create each carousel with a unique ID. In Amazing Carousel, Publish dialog, select the option Publish to Folder, then click Browse to select a folder to save the generated files. You need to set up a unique Carousel ID for each carousel.
We will add a class a row and inside it we will make a 12 columns class for containing our carousel. Inside that we will use how much item we want to show at once like if we want to show 3 items per slide then we will place each columns size to 4 so that 4+4+4=12.
Following are the steps to create a Bootstrap carousel:Apply CSS to resize the . carousel Bootstrap card body by using the code segment below. In this step, the sliding images are defined in the division tag as under. Last step is to add controls to slide images using the carousel-control class as below.
Carousels require the use of an id (in this case id="myCarousel" ) for carousel controls to function properly. The class="carousel" specifies that this <div> contains a carousel. The . slide class adds a CSS transition and animation effect, which makes the items slide when showing a new item.
To avoid this delay, you could manually launch both carousels at the same time, and use customized treatments for events.
$('.carousel-sync').carousel('cycle');
$('.carousel-sync').on('click', '.carousel-control[data-slide]', function (ev) {
ev.preventDefault();
$('.carousel-sync').carousel($(this).data('slide'));
});
$('.carousel-sync').on('mouseover', function(ev) {
ev.preventDefault();
$('.carousel-sync').carousel('pause');
});
$('.carousel-sync').on('mouseleave', function(ev) {
ev.preventDefault();
$('.carousel-sync').carousel('cycle');
});
<div id="carousel-a" class="carousel slide carousel-sync">
...
</div>
<div id="carousel-b" class="carousel slide carousel-sync">
...
</div>
Bootply example
$('.carousel-sync').on('slide.bs.carousel', function(ev) {
// get the direction, based on the event which occurs
var dir = ev.direction == 'right' ? 'prev' : 'next';
// get synchronized non-sliding carousels, and make'em sliding
$('.carousel-sync').not('.sliding').addClass('sliding').carousel(dir);
});
$('.carousel-sync').on('slid.bs.carousel', function(ev) {
// remove .sliding class, to allow the next move
$('.carousel-sync').removeClass('sliding');
});
<div id="carousel-a" class="carousel slide carousel-sync" data-ride="carousel" data-pause="false">
...
</div>
<div id="carousel-b" class="carousel slide carousel-sync" data-ride="carousel" data-pause="false">
...
</div>
Please not the .sliding
class is necessary, to avoid an infinite loop.
Bootply example
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With