I have a project that has a horizontal jquery image carousel. The site is responsive and the carousel needs to have the images get slightly smaller at a certain screen width. I have been able to accomplish this within the css, but the carousel plugin has some javascript settings that I need to change to complete the responsiveness. I have figured out how to work in a media query to get the javascript to change appropriately on page load, but it does not work on resize. Every time I try to include code to change the images on resize the code breaks. Can anybody please help me adapt this code to also work on resize?...
<script type="text/javascript">
$(window).load(function(){
if (document.documentElement.clientWidth < 860) {
$('.flexslider').flexslider({
animation: "slide",
animationLoop: false,
itemWidth: 120,
itemMargin: 5,
pausePlay: false,
start: function(slider){
$('body').removeClass('loading');
}
});
}
$('.flexslider').flexslider({
animation: "slide",
animationLoop: false,
itemWidth: 160,
itemMargin: 5,
pausePlay: false,
start: function(slider){
$('body').removeClass('loading');
}
});
});
</script>