Skip to content

Instantly share code, notes, and snippets.

@joviczarko
Created September 2, 2016 10:21
Show Gist options
  • Save joviczarko/b5e560a61103b3862fc4d8dc674ccd29 to your computer and use it in GitHub Desktop.
Save joviczarko/b5e560a61103b3862fc4d8dc674ccd29 to your computer and use it in GitHub Desktop.
A synced principle for Owl Carousel, so you can make one single, and other with thumbnails. This one is example for videos.
jQuery(document).ready(function($) {
var $sync1 = $(".big-images"),
$sync2 = $(".thumbs"),
flag = false,
duration = 300;
$sync1.owlCarousel({
items: 1,
margin: 10,
nav: false,
dots: false
}).on('changed.owl.carousel', function(e) {
if (!flag) {
flag = true;
$sync2.trigger('to.owl.carousel', [e.item.index, duration, true]);
flag = false;
}
});
$sync2.owlCarousel({
margin: 20,
items: 6,
nav: false,
center: true,
dots: false,
video: false
}).on('click', '.owl-item', function() {
$sync1.trigger('to.owl.carousel', [$(this).index(), duration, true]);
}).on('changed.owl.carousel', function(e) {
if (!flag) {
flag = true;
$sync1.trigger('to.owl.carousel', [e.item.index, duration, true]);
flag = false;
}
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment