3 * Copyright(c) 2006-2010 Ext JS, Inc.
5 * http://www.extjs.com/license
10 Ext.Element.addMethods({
12 * Measures the element's content height and updates height to match. Note: this function uses setTimeout so
13 * the new height may not be available immediately.
14 * @param {Boolean} animate (optional) Animate the transition (defaults to false)
15 * @param {Float} duration (optional) Length of the animation in seconds (defaults to .35)
16 * @param {Function} onComplete (optional) Function to call when animation completes
17 * @param {String} easing (optional) Easing method to use (defaults to easeOut)
18 * @return {Ext.Element} this
20 autoHeight : function(animate, duration, onComplete, easing){
21 var oldHeight = this.getHeight();
23 this.setHeight(1); // force clipping
24 setTimeout(function(){
25 var height = parseInt(this.dom.scrollHeight, 10); // parseInt for Safari
27 this.setHeight(height);
29 if(typeof onComplete == "function"){
33 this.setHeight(oldHeight); // restore original height
34 this.setHeight(height, animate, duration, function(){
36 if(typeof onComplete == "function") onComplete();
37 }.createDelegate(this), easing);
39 }.createDelegate(this), 0);