Line | |
---|
1 | /*! |
---|
2 | * Ext JS Library 3.0.0 |
---|
3 | * Copyright(c) 2006-2009 Ext JS, LLC |
---|
4 | * licensing@extjs.com |
---|
5 | * http://www.extjs.com/license |
---|
6 | */ |
---|
7 | /** |
---|
8 | * @class Ext.Element |
---|
9 | */ |
---|
10 | Ext.Element.addMethods({ |
---|
11 | /** |
---|
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 |
---|
19 | */ |
---|
20 | autoHeight : function(animate, duration, onComplete, easing){ |
---|
21 | var oldHeight = this.getHeight(); |
---|
22 | this.clip(); |
---|
23 | this.setHeight(1); // force clipping |
---|
24 | setTimeout(function(){ |
---|
25 | var height = parseInt(this.dom.scrollHeight, 10); // parseInt for Safari |
---|
26 | if(!animate){ |
---|
27 | this.setHeight(height); |
---|
28 | this.unclip(); |
---|
29 | if(typeof onComplete == "function"){ |
---|
30 | onComplete(); |
---|
31 | } |
---|
32 | }else{ |
---|
33 | this.setHeight(oldHeight); // restore original height |
---|
34 | this.setHeight(height, animate, duration, function(){ |
---|
35 | this.unclip(); |
---|
36 | if(typeof onComplete == "function") onComplete(); |
---|
37 | }.createDelegate(this), easing); |
---|
38 | } |
---|
39 | }.createDelegate(this), 0); |
---|
40 | return this; |
---|
41 | } |
---|
42 | }); |
---|
Note: See
TracBrowser
for help on using the repository browser.