Last active
August 29, 2015 14:02
-
-
Save christopherdro/68e3e668e6793646ad0e 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
$(document).ready(function(){ | |
var maxSlides = 7; //Define the max number of variables we want | |
var tscSlideContainer = $('.swiper-wrapper'); | |
/* Responsive query for swiper on load */ | |
function query() { | |
if(Modernizr.mq('screen and (min-width: 768px) and (max-width: 998px)')) { | |
return 5; | |
} | |
else if(Modernizr.mq('screen and (max-width:767px)')) { | |
return 3; | |
} | |
else { | |
return 7; | |
} | |
} | |
function reInitSlider(num, slider){ | |
slider.params.slidesPerView = num; | |
slider.params.slidesPerGroup = num; | |
slider.reInit(); | |
} | |
/* Responsive query for swiper on window resize */ | |
$(window).resize(function(){ | |
var cbp = query(); | |
if ( maxSlides != cbp){ | |
maxSlides = cbp; | |
reInitSlider(maxSlides, mySwiper); | |
} | |
}); | |
/* Swiper Init */ | |
var initSlides = query(); //Defind the max number of variables we want | |
var mySwiper = new Swiper('.swiper-container',{ | |
slidesPerView: initSlides, | |
slidesPerGroup: initSlides | |
}); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment