PDA

View Full Version : Suggestion on Element.autoHeight()


zkim
11-04-2006, 09:34 AM
Jack,
Love EXT, I just have a small suggestion on autoHeight()...


autoHeight:function( _animate_ ) {
this.clip();
this.setHeight(1);
var height=parseInt(this.dom.scrollHeight,10);
this.setHeight(height, _animate_ );
this.unclip();
}



Thanks -Zack

jack.slocum
11-04-2006, 03:31 PM
Great idea! I will put all the animation vars on it. I will also restore it to it's previous height before starting the animation so it looks right.

jack.slocum
11-04-2006, 03:40 PM
Here's a patch that adds it in:

YAHOO.ext.Element.prototype.autoHeight = function(animate, duration, onComplete, easing){
var oldHeight = this.getHeight();
this.clip();
this.setHeight(1); // force clipping
var height = parseInt(this.dom.scrollHeight, 10); // parseInt for Safari
if(!animate){
this.setHeight(height);
this.unclip();
}else{
this.setHeight(oldHeight); // restore original height
this.setHeight(height, animate, duration, function(){
this.unclip();
if(typeof onComplete == 'function') onComplete();
}.createDelegate(this), easing);
}
};