THE HTML STRUCTURE
When using the plugin, you’ll simply have to apply it to an unordered list with images (optionally with anchors). Make sure the surrounding container is fluid, i.e. has a percentage-based width. (If you put the carousel in a container with a fixed width, it will not adapt. So make sure that your container has a fluid layout.)
<ul id="carousel" class="elastislide-list">
<li><a href="#"><img src="images/1.jpg" alt="image01" /></a></li>
<li><a href="#"><img src="images/2.jpg" alt="image02" /></a></li>
<li><a href="#"><img src="images/3.jpg" alt="image03" /></a></li>
<!-- ... -->
</ul>
Use your preferred ID and call the plugin like this:
$('#carousel').elastislide()
OPTIONS
Elastislide has the following default options:
$.Elastislide.defaults = {
// orientation 'horizontal' || 'vertical'
orientation : 'horizontal',
// sliding speed
speed : 500,
// sliding easing
easing : 'ease-in-out',
// the minimum number of items to show.
// when we resize the window, this will make sure minItems are always shown
// (unless of course minItems is higher than the total number of elements)
minItems : 3,
// index of the current item (left most item of the carousel)
start : 0,
// click item callback
onClick : function( el, position, evt ) { return false; },
onReady : function() { return false; },
onBeforeSlide : function() { return false; },
onAfterSlide : function() { return false; }
};
It is also possible to dynamically add new items to the carousel. The following is an example on how to achieve that:
var carousel = $('#carousel').elastislide();
...
$('#carousel').append("<li><a href="#"><img src="images/10.jpg" alt="image03" /></a></li>");
carousel.add();
Note that if you use the Elastislide for a vertical layout, the height of the container will be automatically set according to how many images you choose to be visible.