Last active
August 26, 2019 11:14
-
-
Save Onepo1ntFive/027f34ddddbe3d1b9a7727880a493f03 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
| function initAdaptiveOwlCarousel(block, options, breakPoint, modClass) { | |
| windowWidth = window.innerWidth; | |
| modClass = typeof modClass !== 'undefined' ? modClass += " owl-carousel" : "owl-carousel"; | |
| if ( windowWidth < breakPoint ) { | |
| block.each(function(el) { | |
| $(this).addClass(modClass).owlCarousel(options); | |
| }) | |
| } else { | |
| block.each(function(el) { | |
| $(this).trigger("destroy.owl.carousel").removeClass(modClass); | |
| }) | |
| } | |
| } | |
| // init some carousel | |
| if ( $(".js-block").length ) { | |
| var windowWidth = window.innerWidth; | |
| var $owlCarousel = $(".js-block"); | |
| var owlOptions = { | |
| /* some stuff */ | |
| }; | |
| initAdaptiveOwlCarousel($owlCarousel, owlOptions, 1240, "owl-carousel-mod-class"); | |
| $(window).on("resize", function() { | |
| initAdaptiveOwlCarousel($owlCarousel, owlOptions, 1240, "owl-carousel-mod-class"); | |
| }); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment