Carousel Widget: Image and Text Example

This example uses the YUI Carousel Widget to showcase an example where each (list) item contains and image and some text. As always, you can use arrow keys to select items, as well as click on an item to select it.

Also in this example, you will see the animation capabilities available in the YUI Carousel Widget. For getting an animated effect during scroll, you will have to set the "animation" configuration setting in the YUI Carousel Widget's constructor, apart from including the YUI Animation utility.

Using the Carousel Widget for displaying items with images and text

This example has the following dependencies:

This example uses progressive enhancement. So, the Carousel is created from an "ordered" list of elements.

Apart from setting the height of the Carousel, we have some more CSS rules to position the text and the images within the Carousel items.

Since we have the elements in place, we can invoke the Carousel's constructor to create the widget. We'll pass an additional argument to the constructor, to set the animation speed. The "animation" configuration setting is an object that takes in the speed (to scroll) in seconds, and the animation effect.

Lets assemble everything together. The full JavaScript reads as follows: