AnythingSlider playground
Add, remove, adjust any or all options so you can see how it works.
by Mottie
HTML
<link rel="stylesheet" href="http://css-tricks.github.com/AnythingSlider/css/anythingslider.css">
<script src="http://css-tricks.github.com/AnythingSlider/js/jquery.anythingslider.js"></script>
<script src="http://css-tricks.github.com/AnythingSlider/js/jquery.easing.1.2.js"></script>
<script src="http://css-tricks.github.com/AnythingSlider/js/swfobject.js"></script>
<script src="http://css-tricks.github.com/AnythingSlider/js/jquery.anythingslider.fx.js"></script>
<script src="http://css-tricks.github.com/AnythingSlider/js/jquery.anythingslider.video.js"></script>
<div id="size">...</div>
<ul id="slider">
<li><img src="http://placekitten.com/300/200" alt="" /></li>
<li><img src="http://placehold.it/300x200" alt="" /></li>
<li><img src="http://placebear.com/300/200" alt="" /></li>
<li><img src="http://lorempixel.com/300/200" alt="" /></li>
<li><img src="http://placedog.com/300/200" alt="" /></li>
</ul>
CSS
/*** Set Slider dimensions here! Version 1.7+ ***/
/* added #slider li to make panels the same size in case "resizeContents" is false */
ul#slider, ul#slider li {
width: 300px;
height: 200px;
list-style: none;
}
JavaScript
/*
https://github.com/CSS-Tricks/AnythingSlider/issues/414
IF browser width is more or equal to 320, I want my slider to showMultiple: 1 & changeBy: 1
IF browser width is more or equal to 640, I want my slider to showMultiple: 2 & changeBy: 1
IF browser width is more or equal to 960, I want my slider to showMultiple: 3 & changeBy: 1
*/
var multi, w, timer, slider = $('#slider'),
win = $(window),
checkWidth = function() {
multi = 3;
w = win.width();
if (w >= 640 && w < 960) {
multi = 2;
} else if (w < 640) {
multi = 1;
}
// update AnythingSlider
slider.data('AnythingSlider').options.showMultiple = multi;
slider.anythingSlider();
// show width for demo
$('#size').text('width = ' + w + '; multi = ' + multi);
};
win.resize(function() {
clearTimeout(timer);
// throttle the resize check
timer = setTimeout(function() {
checkWidth();
}, 200);
});
slider.anythingSlider({
// Set this value to a number and it will show that many slides at once
showMultiple: multi,
// Amount to go forward or back when changing panels.
changeBy: 1
});