Feed on
Posts
Comments

Update: the latest version of the Infinite Carousel plugin can be found here.

As announced earlier, I’m happy to release version 2 of the jQuery Infinite Carousel plugin. What happened to versions 1.3-1.9 you ask? Well, since I overhauled the old plugin and added so many new features, it just seemed fitting to brand this release with a whole new version number. Heck I could’ve named it version Infinite Carousel, the “Illudium Q-36 Explosive Space Modulator” edition, but it seemed a bit wordy. Anyway, like it matters. All you want is the plugin right?

So What’s New?

Where to begin? Based on feedback from users, I’ve added more options than you can shake a stick at. Go on, get a stick. Shake. Can’t be done. There are so many new features that I was a bit worried that the plugin might suffer from option overload, but in the end I think what remained was not only useful but vital to the plugin.

In addition to the features in the previous version, I’ve added the ability to:

  • add easing as an option with separate left and right easing effects
  • specify the path to the navigation images as an option
  • specify how many images should be viewable at once
  • specify padding around images
  • specify how many images should advance when the user navigates using the previous and next controls as well as when the carousel is running automatically
  • hide navigation controls
  • auto hide navigation controls so that they appear only when the user moves their mouse over the carousel
  • auto hide captions so that they appear only when the user moves their mouse over the carousel
  • prevent the carousel from automatically starting
  • move the previous and next navigation control outside the carousel so that they don’t appear on top of any images
  • use keyboard navigation with the ability to disable it (left and right arrows for previous/next, p for pause, s for start)
  • access callback functions

The Most Basic Example

Download

jQuery.InfiniteCarousel2.zip (contains the uncompressed and minified versions in the same zip file. The uncompressed plugin is about 18k while the minified version is about 9k)

Demos

To show off some of the things version 2 can do, I’ve created several demo pages for easy viewing. Each demo link will open in a new window. View the source code for a demo to see the options that were selected.

  1. A basic example with default settings
  2. Displaying and advancing more than one image at a time
  3. Displaying multiple images while advancing one at a time with easing effects
  4. Navigation outside the carousel with captions automatically hidden
  5. Thumbnails and navigation hidden. Keyboard navigation active
  6. Navigation automatically hidden with keyboard controls disabled. Also shows how to hint at the next and last images using CSS
  7. An example of callback functions
  8. An example of how easy it is to integrate with a lightbox plugin. Easing functions are also being used in this example
  9. An infinitely scrolling slideshow with no controls enabled

How to Use

With the exception of new options, the carousel works in the same way as previous versions. First, all of the images that you want to display should be the same size and wrapped in a containing element (I recommend a div) which must have an ID.  Note that by using CSS, you can style the container (carousel) div to have left and/or right padding so that you can display a small amount of the previous and/or next images (see demo #6 above). The carousel must be a list where each list item is the image and optionally a paragraph containing the caption. See this example.

<div id="carousel">
<ul>
	<li><img alt="" src="p1.jpg" width="500" height="213" /><p>This carousel has no padding applied to it so you won't see hints for the previous and next images. Also, the progress bar could be disabled by setting just one option on the plugin.</p></li>
	<li><img alt="" src="p2.jpg" width="500" height="213" /><p>This is the caption for the second image. The height of the caption box is an option.</p></li>
	<li><img alt="" src="p3.jpg" width="500" height="213" /></li>
	<li><img alt="" src="p4.jpg" width="500" height="213" /><p>It's not easy being green.</p></li>
	<li><img alt="" src="p5.jpg" width="500" height="213" /></li>
	<li><img alt="" src="p6.jpg" width="500" height="213" /><p>You can easily mix images types. Gif, png, and jpeg all work without any issues.</p></li>
</ul>
</div>

All images *MUST* have the width and height declared otherwise the plugin won’t work in Safari, Chrome, and any other webkit-based browsers. Also, all images should be the same size.  If you want to have a caption with an image, it *MUST* exist in a paragraph after the image.

To use the plugin you’ll need to have a copy of  jQuery, or point to jquery on Google, and the plugin. Place the files on your site and link to them:

<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1.3.2/jquery.min.js"></script>
<script type="text/javascript" src="jquery.infinitecarousel-2.0.0.js"></script>
<script type="text/javascript">
$(function(){
	$('#carousel').infiniteCarousel();
});
</script>

Finally, make sure that your CSS contains a rule for the width of the list within your container so that it’s set to a minimum of the combined widths of all your images. For example. #carousel ul {width:3000px}. In version 1.2 of the Infinite Carousel this isn’t necessary, however for anyone with JavaScript disabled, declaring the width in your style sheet can give them a simulated (albeit limited) carousel experience.

Be sure to check out the demos above!

Note that in this new version of the carousel, since the path to the navigation images is an option, you may need to specify the path to your installation if you aren’t using the path of “/js/infinitecarousel/images/” which is the plugin’s default path. More on the options below.

That’s it! You can apply the infinite carousel to any number of elements on a page.

Options

The following options are configurable:

  • transitionSpeed – the time (in milliseconds) it will take to transition between two images (default 800)
  • displayTime – the time (in milliseconds) to display each image (default: 6000)
  • textholderHeight – the height of the caption. This is a fraction of the height of the images. (default: .25)
  • displayProgressBar – Boolean. Whether or not to display the progress bar (default: true)
  • displayThumbnails – Boolean. Whether or not to display the thumbnails for the carousel. (default:  true)
  • displayThumbnailNumbers – Boolean. Whether or not to automatically place numbers in the thumbnail boxes. (default: true)
  • displayThumbnailBackground – Boolean. Whether or not to use the corresponding image as the background for a thumbnail box. (default: true)
  • thumbnailWidth – the width of each thumbnail box. (default: ’20px’)
  • thumbnailHeight – the height of each thumbnail box. (default: ’20px’)\
  • thumbnailFontSize – the font size of the number within the thumbnail box. (default: .7em)
  • easeLeft – The type of easing to use when the carousel moves images to the left. Here you can use the jQuery easing plugin and specify any type of easing, or use jQuery’s built-in defaults of ‘linear’ or ‘swing’. (default:  ‘linear’)
  • easeRight- The type of easing to use when the carousel moves images to the right. Here you can use the jQuery easing plugin and specify any type of easing, or use jQuery’s built-in defaults of ‘linear’ or ‘swing’. (default:  ‘linear’)
  • imagePath – The path to the carousel’s navigation images (now sprites). (default: ‘/js/infinitecarousel/images/’)
  • inView – The number of images to display at once. (default: 1)
  • padding – The amount of padding to be applied around each image. (default:  ’0px’)
  • advance – The number of images to be moved either automatically, or when the user moves images by using the navigation controls. (default: 1)
  • showControls – Boolean. Whether or not to display the navigation buttons for previous, next, play and pause. (default: true)
  • autoHideControls – Boolean. Whether or not to automatically hide the navigation controls. (default: false)
  • autoHideCaptions – Boolean. Whether or not to automatically hide the captions (if any). (default: false)
  • autoStart – Boolean. Whether or not to automatically begin the carousel. (default: true)
  • prevNextInternal – Boolean. Display the navigation on the inside of the carousel. If false, controls will be dispayed outside and next to the carousel. (default: true)
  • enableKeyboardNav – Boolean. Enable keyboard navigation (kind of obvious no?). The left and right arrows are used to move the images, while ‘p’ pauses the show and ‘s’ starts it. (default: true)
  • onSlideStart. A callback function triggered when the images begin to move
  • onSlideEnd. A callback function triggered when the images stop moving. An array of images being displayed is returned
  • onPauseClick. A callback function triggered when the carousel is paused

Options are added when calling the script:

$('#carousel').infiniteCarousel({
	transitionSpeed : 2000,
	displayTime : 10000,
	textholderHeight : .25,
	displayProgressBar : false
});

Note that the CSS of the thumbnail div created by the plugin can be controlled by using a rule like #carousel + div {your CSS here}. The plus between the carousel id and the div specifically targets the thumbnail container.

Enjoy!

Previous Version

I will continue to make the previous versions of the Infinite Carousel available until there seems to be no demand for them. To download them, click here.

218 Responses to “Huge Updates to jQuery Infinite Carousel – Version 2 Released”

Trackbacks/Pingbacks

Leave a Reply

You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>