$(function(){ SyntaxHighlighter.all(); }); $(window).load(function(){ $('.flexslider').flexslider({ animation: "slide", animationLoop: false, itemWidth: 1170, itemMargin: 5, pausePlay: true, start: function(slider){ $('body').removeClass('loading'); } }); function getGridSize() { return (window.innerWidth < 480) ? 1 : (window.innerWidth < 700) ? 2 : (window.innerWidth < 900) ? 3 : 4; } $('.flexslider2').flexslider({ animation: "slide", animationLoop: true, itemWidth: 280, itemMargin: 13, pausePlay: true, minItems: getGridSize(), // use function to pull in initial value maxItems: getGridSize(), // use function to pull in initial value start: function(slider){ $('body').removeClass('loading'); } }); $(window).resize(function() { var gridSize = getGridSize(); flexslider.vars.minItems = gridSize; flexslider.vars.maxItems = gridSize; }); });