Element.fall()

Snippets are small pieces of code that do not fit in the UvumiTools plugin category. Please note that each of these semi-useful functions requires Mootools 1.2.

Difficult to describe in few words, instead please examine the demo to see what this does. Just know that you can pass an element as a target, or an object with X and Y pixel coordinates, or simply nothing. In that last case the target will be the center of the screen.
It also accepts a second parameter, to set the animation options. Just pass a same object you'd pass to a regular Fx instance (duration, transition, onComplete...).

Element.implement({
fall : function(target,options){
var options = options || {transition:Fx.Transitions.Bounce.easeOut,duration:800};
var size = this.getSize();
var winSize = window.getSize();
var winScroll = window.getScroll();
switch($type(target)){
case 'element':
case 'string':
var coords = $(target).getCoordinates(); target = {
left:coords.left+((coords.width-size.x)/2).toInt(),
top:coords.top+((coords.height-size.y)/2).toInt()
}
break;
case 'object':
if(target.x && target.y){
target = {
left:target.x-(size.x/2).toInt(),
top:target.y-(size.y/2).toInt()
}
break;
}
default:
target = {
left:((winSize.x-size.x)/2).toInt()+winScroll.x,
top:((winSize.y-size.y)/2).toInt()+winScroll.y
}
break;
}
target.width=size.x;
target.height=size.y;
this.setStyles({
display:'none',
position:'absolute',
width:winSize.x,
height:(winSize.x*size.y/size.x).toInt(),
left:winScroll.x,
top:winScroll.y+winSize.y/2-(winSize.x*size.y/(2*size.x)).toInt()
}).inject($(document.body)).setStyle('display','block').get('morph',options).start(target);
return this;
}
});

Usage:

$('myElement').fall();                     //falls in the middle of the screen
$('myElement').fall($('myOtherElement'));  //falls centered on the passed element (this example)
$('myElement').fall($({x:120,y:200}));     //falls centered on the passed coordinates

Demo:

dummy