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>
<link rel="stylesheet" href="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8/themes/ui-lightness/jquery-ui.css">
<!-- Add additional stylesheets here -->
<link rel="stylesheet" href="http://css-tricks.github.com/AnythingSlider/css/theme-metallic.css">
<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>
<div id="ui-slider"></div>
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;
}
/* set width of the jQuery UI slider */
#ui-slider {
margin: 20px auto;
width: 400px;
}
JavaScript
$('#slider').anythingSlider({
// If true, builds a list of anchor links to link to each panel
buildNavigation: false,
// Callback when the plugin finished initializing
onInitialized: function(e, slider) {
$( "#ui-slider" ).slider({
value: slider.currentPanel,
min: 1,
max: slider.pages,
step: 1,
stop: function( event, ui ) {
slider.gotoPage( ui.value );
}
});
},
// Callback when slide completes - no event variable!
onSlideBegin: function(e, slider) {
// update the slider ui
// luckly setting the value doesn't call the slider ui
// "stop" callback and cause an infinite loop
$('#ui-slider').slider( "value" , slider.targetPage );
}
});