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