Last active
March 28, 2017 15:10
-
-
Save edelmtl/718244936efc0701ab1547ab9932bc93 to your computer and use it in GitHub Desktop.
Owl Carousel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var owl = $('.owl-carousel'), | |
owlOptions = { | |
loop: false, | |
margin: 10, | |
responsive: { | |
0: { | |
items: 1 | |
} | |
} | |
}; | |
if ( $(window).width() < 768 ) { | |
var owlActive = owl.owlCarousel(owlOptions); | |
} else { | |
owl.addClass('off'); | |
} | |
$(window).resize(function() { | |
if ( $(window).width() < 768 ) { | |
if ( $('.owl-carousel').hasClass('off') ) { | |
var owlActive = owl.owlCarousel(owlOptions); | |
owl.removeClass('off'); | |
} | |
} else { | |
if ( !$('.owl-carousel').hasClass('off') ) { | |
owl.addClass('off').trigger('destroy.owl.carousel'); | |
owl.find('.owl-stage-outer').children(':eq(0)').unwrap(); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment