Jonathan Snook debuted a great tutorial last September detailing how you can use an image and a few jQuery techniques to create a slick mouseover effect. I revisited his article and ported its two most impressive effects to MooTools.
The Images

These are the same images used in Snook’s article.
The XHTML
<h2>Example 0: No Script</h2> <ul id="noscript"> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> </ul> <h2>Example A: Top down</h2> <ul id="a"> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> </ul> <h2>Example B: Right left</h2> <ul id="b"> <li><a href="#">Home</a></li> <li><a href="#">About</a></li> <li><a href="#">Contact</a></li> </ul>
Three menus. The first will be a simple CSS-only mouseover, the other two will be varying MooTools versions.
The CSS
ul { list-style:none; margin:0; padding:0; }
li { float:left; width:100px; margin:0; padding:0; text-align:center; }
li a { display:block; padding:5px 10px; height:100%; color:#fff; text-decoration:none; border-right:1px solid #fff; }
li a { background:url(snook-animation-bg2.jpg) repeat 0 0; }
a:hover, a:focus, a:active { background-position:-150px 0; }
#a a { background:url(snook-animation-bg.jpg) repeat; background-position:-20px 35px; }
#b a { background:url(snook-animation-bg2.jpg) repeat; background-position:0 0; }
Nothing too notable here.
The MooTools JavaScript
window.addEvent('domready', function() {
/* example a: top down */
$$('#a a').each(function(el) {
//fx
var fx = new Fx.Tween(el,{
duration: 500,
link: 'cancel'
});
//css & events
el.setStyle('background-position','-20px 35px').addEvents({
'mouseenter': function(e) {
e.stop();
fx.start('background-position','-20px 94px');
},
'mouseleave': function(e) {
e.stop();
fx.start('background-position','-20px 35px');
}
});
});
/* example b: right left */
$$('#b a').each(function(el) {
//css
var reset = false;
var fx = new Fx.Tween(el,{
duration: 500,
link: 'cancel',
onComplete:function() {
if(reset) {
el.setStyle('background-position','0 0');
}
}
});
//events
el.setStyle('background-position','0 0').addEvents({
'mouseenter': function(e) {
e.stop();
fx.start('background-position','-150px 0');
reset = false;
},
'mouseleave': function(e) {
reset = true;
fx.start('background-position','-300px 0');
}
});
});
});
When you mouseover the last two navigation menu links, the background image animates from one spot to another creating a flash-like effect.