Carousel with wrap effect
- » Overview
- » Example:
- » Usage & params
- » Notes
Overview
This carousel actually wraps slides as they're bumped off the edges. That is, if a slide is bumped off the right edge, it reappears in equal measure from the left edge. The 'on' slide is always centered, widened and given full opacity. The other slides huddle around it, narrower and semi-opaque. An auto-rotator turns on each slide in turn, or you can force a slide on by clicking it (interrupting the auto-rotate). Clicking the 'on' slide takes you to its corresponding URL, specified in the config file.
Example:
Let the slides auto-rotate, or click one to force it on. Click the 'on' slide to go to its URL.
Usage & params
The only thing to do at page level is to set up a container that the carousel will be inserted into. For the example above, I used:
All the actual preferences and styling are set in the script file itself, in the clearly-marked 'PREFERENCES' and 'STYLING' sections respectively.
All data regarding the actual slides (image SRCs, caption text etc) is set in the JSON-formatted config.txt file. As you'll see in there, each slide's data is wrapped in curly braces.
The params you can edit in the script file include:
Preferences
pathTo_configFile (string) - the path to the slides data config file (relative to the page)
pathTo_imgsDir (string) - the path to the directory where your slide images are
spaceBetweenSlides (integer) - pixel value of the space separating each slide from its neighbours
startSlideOutDuration (integer) - when the carousel loads, the slides animate to their starting positions. This is the number of seconds that animation takes.
transitionDuration (objject) - the speed in seconds of the visual transition between turning the 'on' slide off and turning the next one on
css.pauseDuration (integer) - the duration during auto rotation that a slide will be 'on' before it is turned off and the next one turned on
CSS
wrapper (obj.) - CSS to style the main wrapper for the entire carousel
carousel (obj.) - CSS to style the carousel itself (i.e. the that holds the slides)
slides (obj.) - CSS to style the slides
slide_on (obj.) - CSS to style the 'on' (i.e. centered) slide
captionHolders (obj.) - CSS to style the wrapper around each slide's caption headline and text
captionHeadings (obj.) - CSS to style the caption heading for each slide
captionText (obj.) - CSS to style the caption text for each slide
pauseIcon (obj.) - when the mouse enters the carousel area, the auto-rotate feature stops; that is, the carousel is paused. An || pause icon is DOM-scripted onto the carousel to denote this - you can style it here.
Download the source code ZIP to see how I've set up the config and styling on the demo carousel above.
Notes
Use odd number of slides
Make sure you have an odd number of slides, otherwise it will look odd because the 'on' slide is centered. If there were, say, 4 slides, the 'on' slide would have an unequal number of slides either side of it.
Dependencies (nearly none!)
The only HTML dependency is an element to act as a container for the carousel. Apart from that, there are no HTML or CSS dependencies - everything is done by the script.
Also, as of 10 Sept 2010, there is no dependency on my Domscripter script (this was previously pulled in to help out with creating the elements that make up the carousel).
I hate IE
For a reason I cannot yet fathom, IE errors when trying to do the transition animation. I spent an hour trying to debug this and hit a blank. Unfortunately, this means that, in IE, for now at least, the transition is immediate, not animated. In decent browsers, all looks lovely.
Comments (14)
siteHELP, at 25/09/'10 00:14, said:
Mitya, at 28/09/'10 11:42, said:
web.design, at 7/10/'10 13:21, said:
Mitya, at 7/10/'10 14:00, said:
, at 10/10/'10 10:32, said:
stan stefano, at 4/11/'10 13:03, said:
Mitya, at 7/11/'10 12:52, said:
stan stefano, at 8/11/'10 15:13, said:
Mitya, at 8/11/'10 15:23, said:
Okoweb, at 29/12/'10 07:25, said:
OKoweb, at 29/12/'10 07:33, said:
Mitya, at 29/12/'10 09:20, said:
OKoweb, at 30/12/'10 06:26, said:
mitya, at 31/12/'10 19:08, said: