The Slide Transition Pattern is a design pattern used when you want to expose data strongly associated with content currently on the page. An example would be a photo browser (e.g., Flickr) where you would typically have a scrolling list of thumbnails and the currently displayed photo. You don't want the list in another window because the association between the thumbnails and the active photo wouldn't be apparent.
Code speaks louder than words, so here you go. I can only vouch for it working in Firefox and Safari.

Pretty picture 1
Pretty picture 2
Pretty picture 3
Pretty picture 4
Pretty picture 5
Pretty picture 6
Pretty picture 7
Pretty picture 8
How it Works
There are two requires parts: a container window and the sliding box. The container window is set to a fixed width, probablu some multiple of the size of each of the items in the list. It has overflow: hidden set so that all items not currently placed inside the window are hidden.
The sliding box is then given a width large enough to contain all the items. Whenever you click on the buttons it is moved to the left (or right) the appropriate distance. The distance is calculated from the dimensions of each of the items in the box.
Usage
The central class is called WidnowBox, which takes three parameters as input.
- box
- The box containing the items to slide.
- className (optional)
- The class name associated with one item in the list. Defaults to box-item.
- windowContainer (optional)
- The container window for the slider. Defaults to the parent node of the slider.
- slideWidth (optional)
- The number of items to slide by per click (e.g., 2). Defaults to the size of the window minus 1.
That's all she wrote. A sensible extension would be to allow the slider to move more than one unit at a time, but I'll leave that for another day.
Update: I spent a few minutes adding a "slideWidth" parameter (see the Usage section above). I think the effect is better, now, at least by default. It's all configurable.
Thx for this insight, it is a nice effect, and it does need some more polishing. E.g. try clicking on the “buttons” (div/s). Perhaps the distance should be calculated by taking into consideration the overall window dimension (width) as well?
Cheers,
pizon
Sorry, missed the key-word in the previous comment. So, try clicking on the buttons quickly multiple times…
Yep. I noticed that, too. Unfortunately I don’t know how to queue effects in YUI. I also have a scriptaculous version of this Pattern which doesn’t suffer from that problem.
[…] Slide Transition Pattern in YUI (tags: Slideshows) Share and Enjoy:These icons link to social bookmarking sites where readers can share and discover new web pages. […]
I am trying to get some functionality like this working on my own site. Unfortunately, like this example, I can’t get it working in IE. I find that the overflow stops working properly as soon as you click on the buttons. What happens is that all the images are shown, even the ones outside the box.
This totally works for what it is–thanks for sharing it Jesse! But folks looking for a more robust version may want to check out Bill W. Scott’s carousel component: http://billwscott.com/carousel/