Simplest Prototype & scripty Slideshow
December 11th, 2009 by Thomas Fuchs, 4 comments »Here’s a more extended version of my comment on Jonathan Snook’s post on the simplest jQuery Slideshow (good article!).
So here’s my version of the simplest slideshow (done in Prototype/script.aculo.us 1.8), compare to Jonathan’s version in jQuery.
I’ve optimized what’s going on by only fading on element at a time (versus a more processor-hungry crossfade).
The code:
setInterval(function(){
var imgs = $$('.fadein img'),
visible = imgs.findAll(function(img){ return img.visible(); });
if(visible.length>1) visible.last().fade({ duration: .3 });
else imgs.last().appear({ duration: .3,
afterFinish: function(){ imgs.slice(0,imgs.length-1).invoke('show'); } });
}, 3000);
I don’t really like either my Prototype/scriptaculous nor the jQuery version (which seems too magic for my taste, plus it does two animations at the same time). The main issue with my code is that the CSS has to be reset after a cycle is complete, and this ends up to be quite complicated.
I guess it’s food for thought.
Tweet This Post
Digg This Post
Share on Facebook









Looks nice, I use such quick liners for rapid prototyping ( I had 5 – line tab panel ). If you want to make it even smaller you could replace img.visible() function with Element.visible
I think the fact that you find the jQuery version ‘too magic’ is indicative of the philosophical differences between JQ and Protoype/Scripty, rather than an objective problem with Simon’s code. I used to find jQuery code unnecessarily terse and illegible, especially when it employed `.end()` call-chaining, but gradually it has come to seem natural to me. The Prototype coding style encourages idiomatic javascript, with named variables and ordinary control structures, whereas the jQuery style is more like a little DSL for the DOM, where logic is done in call-chaining and verbosity is considered redundant.
[...] that, Thomas Fuchs, the author of the script.aculo.us, has also created one using Prototype & Scripty [...]
Here’s my version: http://qfox.nl/weblog?181.
Slideshows are all about fading these days. The rest is sugar…