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