Flash Without Flash: Grid Slide In
October 16th, 2007 in flash without flash | 5 Comments
The effect I’m reproducing this time can be found at Got Character. Notice how the images slide in. Clicking on Gallery will allow you to see the effect more fully. Here is my version. You’ll notice that it is very similar to the original slide in effect, and that’s because it is. I only changed a few lines.
JavaScript
var SlideIn = { start: function () { var delay = 200; $$('img').each(function (el) { el.setStyles({ 'position': 'relative', 'top': el.getParent().offsetTop - el.offsetTop, 'left': el.getParent().offsetLeft - el.offsetLeft, 'opacity': 0 }); var fx = el.effects({transition:Fx.Transitions.Back.easeOut}); fx.start.delay(delay, fx, { 'opacity': 1, 'top': 0, 'left': 0 }); delay += 100; }); } }; window.addEvent('load', SlideIn.start);
To make every image animate from the same start point, I got the parent’s top and left CSS value and subtracted the image’s top and left value. That works because I set the image’s position to relative. Then I just create an effect that will animate the image’s location back to 0, where it would normally appear in the layout.
Modifications
This is the same modification as in the original slide in, but solves an additional problem. If you don’t want the images to appear before the effect occurs (and who wouldn’t?) but still allow people without JavaScript to view the images, you can create an extra CSS file that adds a visibility: hidden rule to images and load that with Mootools using the Assets class. This line should be placed outside of any load or domready functions and will add the css file to the head:
new Asset.css('style_js.css');
That way, you know the images aren’t hidden if the user doesn’t have JavaScript, plus it will hide the images without a flicker because the rule is applied even before the images are loaded.

Hi, I'm Chris, a passionate freelance web developer. My languages of choice are PHP and JavaScript, and that's what you'll mostly find in my blog. You'll also find updates about 