Created
April 18, 2020 15:34
-
-
Save alessandroalessio/c57171db5c53354f85b367ad7c5f00b5 to your computer and use it in GitHub Desktop.
owlCarousel 2 managed by Data Attribute
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
// Carousel | |
if ( jQuery('.owl-carousel').length ) { | |
jQuery.each( jQuery('.owl-carousel'), function(){ | |
var owlItems = jQuery('.owl-carousel').data('items') ? jQuery('.owl-carousel').data('items') : 3; | |
owlOptions = []; | |
if ( typeof jQuery(".owl-carousel").data('items') !== 'undefined' ) owlOptions['items'] = jQuery(".owl-carousel").data('items'); | |
if ( typeof jQuery(".owl-carousel").data('loop') !== 'undefined' ) owlOptions['loop'] = jQuery(".owl-carousel").data('loop'); | |
if ( typeof jQuery(".owl-carousel").data('margin') !== 'undefined' ) owlOptions['margin'] = jQuery(".owl-carousel").data('margin'); | |
if ( typeof jQuery(".owl-carousel").data('nav') !== 'undefined' ) owlOptions['nav'] = jQuery(".owl-carousel").data('nav'); | |
if ( typeof jQuery(".owl-carousel").data('dots') !== 'undefined' ) owlOptions['dots'] = jQuery(".owl-carousel").data('dots'); | |
if ( typeof jQuery(".owl-carousel").data('autoplay') !== 'undefined' ) owlOptions['autoplay'] = jQuery(".owl-carousel").data('autoplay'); | |
if ( typeof jQuery(".owl-carousel").data('autoplay-timeout') !== 'undefined' ) owlOptions['owlAutoplayTimeout'] = jQuery(".owl-carousel").data('autoplay-timeout'); | |
var $carousel = jQuery(this); | |
$carousel.owlCarousel(owlOptions); | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment