Skip to content

Instantly share code, notes, and snippets.

@rhcarlosweb
Last active February 18, 2021 15:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save rhcarlosweb/0b0e5338a1c9a06276f5f1e3fc312a20 to your computer and use it in GitHub Desktop.
Save rhcarlosweb/0b0e5338a1c9a06276f5f1e3fc312a20 to your computer and use it in GitHub Desktop.
Owl Carousel 2 Sync Two Sliders
var sync1 = $('#sync1'),
sync2 = $('#sync2'),
duration = 300,
thumbs = 4;
// Sync nav
sync1.on('click', '.owl-next', function () {
sync2.trigger('next.owl.carousel')
});
sync1.on('click', '.owl-prev', function () {
sync2.trigger('prev.owl.carousel')
});
// Start Carousel
sync1.owlCarousel({
// rtl: true,
// center: true,
loop: true,
items: 1,
margin: 0,
smartSpeed: 700,
lazyLoad: true,
autoplay: true,
autoplayTimeout: 5000,
autoplayHoverPause: true,
nav: true,
navText: ['<i class="fa fa-angle-left"></i>', '<i class="fa fa-angle-right"></i>']
}).on('dragged.owl.carousel', function (e) {
if (e.relatedTarget.state.direction == 'left') {
sync2.trigger('next.owl.carousel')
} else {
sync2.trigger('prev.owl.carousel')
}
});
sync2.owlCarousel({
// rtl: true,
loop: true,
items: thumbs,
margin: 2,
autoplay: true,
autoplayTimeout: 5000,
autoplayHoverPause: true,
smartSpeed: 700,
nav: false,
// center: true,
responsive: {
0: {
items: 3
},
768: {
items: 4
}
}
}).on('click', '.owl-item', function () {
var i = $(this).index() - (thumbs + 1);
sync2.trigger('to.owl.carousel', [i, duration, true]);
sync1.trigger('to.owl.carousel', [i, duration, true]);
});
<div class="owl-carousel" id="sync1">
Item
Item
</div>
<div class="owl-carousel" id="sync2">
Item
Item
</div>
@zdimaz
Copy link

zdimaz commented Apr 29, 2020

Bugs syns!!!
If drag for more slides.....((((

@rhcarlosweb
Copy link
Author

rhcarlosweb commented Apr 29, 2020 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment