3 <title>The source code</title>
\r
4 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
\r
5 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
\r
7 <body onload="prettyPrint();">
\r
8 <pre class="prettyprint lang-js">/**
\r
11 Ext.Element.addMethods({
\r
12 <div id="method-Ext.Element-autoHeight"></div>/**
\r
13 * Measures the element's content height and updates height to match. Note: this function uses setTimeout so
\r
14 * the new height may not be available immediately.
\r
15 * @param {Boolean} animate (optional) Animate the transition (defaults to false)
\r
16 * @param {Float} duration (optional) Length of the animation in seconds (defaults to .35)
\r
17 * @param {Function} onComplete (optional) Function to call when animation completes
\r
18 * @param {String} easing (optional) Easing method to use (defaults to easeOut)
\r
19 * @return {Ext.Element} this
\r
21 autoHeight : function(animate, duration, onComplete, easing){
\r
22 var oldHeight = this.getHeight();
\r
24 this.setHeight(1); // force clipping
\r
25 setTimeout(function(){
\r
26 var height = parseInt(this.dom.scrollHeight, 10); // parseInt for Safari
\r
28 this.setHeight(height);
\r
30 if(typeof onComplete == "function"){
\r
34 this.setHeight(oldHeight); // restore original height
\r
35 this.setHeight(height, animate, duration, function(){
\r
37 if(typeof onComplete == "function") onComplete();
\r
38 }.createDelegate(this), easing);
\r
40 }.createDelegate(this), 0);
\r