Skip to content

Instantly share code, notes, and snippets.

@fiximportant
Created April 5, 2018 11:58
Show Gist options
  • Save fiximportant/46e29d6d3ad4affb2ccf5e0a65ce787b to your computer and use it in GitHub Desktop.
Save fiximportant/46e29d6d3ad4affb2ccf5e0a65ce787b to your computer and use it in GitHub Desktop.
OwlCarousel - Breakpoints
function CarouselInit() {
var checkWidth = $(window).width();
var carousel = $(".js-carousel-catmain");
if (checkWidth < 980) {
carousel.addClass('owl-carousel').owlCarousel({
items: 1,
margin: 20,
nav: true,
navText: [],
dots: false,
responsive: {
0: {
items: 1,
autoHeight: true
},
768: {
items: 2
},
980: {
items: 3
},
1240: {
items: 3
}
}
});
} else {
if (carousel.data('owlCarousel') != 'undefined') {
carousel.trigger('destroy.owl.carousel').removeClass('owl-carousel');
}
}
};
$(document).ready(CarouselInit);
$(window).resize(CarouselInit);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment