section idea/code by Sylvia Tashev
Today we will write an animated photo gallery using Scriptaculous. Start with this skeleton:
pictures.html
(complete HTML/CSS code)pictures.js
(skeleton of JS code)
Click the following image to run our sample solution: (solution JS code pictures.js
)
Right now, when you double-click an image, it shows in the large mainimage
area. But it's boring! Add Scriptaculous effects such as the following:
mainimage
image (the first one) should scale up to 200% of its normal size, and the mainimage
image should have a visual effect, such as shaking.
mainimage
image should shake as it changes. Also the old selected thumbnail should shrink back to its previous size. Note that if you double-click on the same thumbnail twice in a row, it shouldn't break.
Note that you can easily access neighbors of an element using Prototype's previous
and next
methods.
tag
and constraint
.
mainimage
area, the large image will update. (This is the same behavior as when the thumbnail is double-clicked. See the Scriptaculous Wiki pages about dragging and dropping.
mainimage
is updated, make it have two effects in a row, such as highlighting and then shaking.
References: Scriptaculous wiki, JSLint