proprio al volo,
ci sono 10000 modi di farlo meglio
codice:
var timer=false;
function $(id){
return document.getElementById(id);
}
function setval(x,fx){
var m=(x<fx)?1:-1;
x=x+((2+(((fx-x)/4)*m))/(2*0.8))*m;
if((m>0 && x>fx)||(m<0 && x<fx)) x=fx;
return x;
}
function setH(fh){
el=$('contenitore');
var h=setval(parseInt(el.style.height),fh);
el.style.height=h+'px';
if(h!=fh){
timer=setTimeout("setH("+fh+")", 50);
}
}
function rSetH(fh){
if(timer) clearTimeout(timer);
setH(fh);
}
codice:
rSetH: 200 | 20 | 100
<div id="contenitore" style="height:120px;"></div>
ciao