Upgrade to ExtJS 4.0.0 - Released 04/26/2011
[extjs.git] / docs / source / Element.html
1 <!DOCTYPE html><html><head><title>Sencha Documentation Project</title><link rel="stylesheet" href="../reset.css" type="text/css"><link rel="stylesheet" href="../prettify.css" type="text/css"><link rel="stylesheet" href="../prettify_sa.css" type="text/css"><script type="text/javascript" src="../prettify.js"></script></head><body onload="prettyPrint()"><pre class="prettyprint"><pre><span id='Ext-fx.target.Element'>/**
2 </span> * @class Ext.fx.target.Element
3  * @extends Ext.fx.target.Target
4  * 
5  * This class represents a animation target for an {@link Ext.core.Element}. In general this class will not be
6  * created directly, the {@link Ext.core.Element} will be passed to the animation and
7  * and the appropriate target will be created.
8  */
9 Ext.define('Ext.fx.target.Element', {
10
11     /* Begin Definitions */
12     
13     extend: 'Ext.fx.target.Target',
14     
15     /* End Definitions */
16
17     type: 'element',
18
19     getElVal: function(el, attr, val) {
20         if (val == undefined) {
21             if (attr === 'x') {
22                 val = el.getX();
23             }
24             else if (attr === 'y') {
25                 val = el.getY();
26             }
27             else if (attr === 'scrollTop') {
28                 val = el.getScroll().top;
29             }
30             else if (attr === 'scrollLeft') {
31                 val = el.getScroll().left;
32             }
33             else if (attr === 'height') {
34                 val = el.getHeight();
35             }
36             else if (attr === 'width') {
37                 val = el.getWidth();
38             }
39             else {
40                 val = el.getStyle(attr);
41             }
42         }
43         return val;
44     },
45
46     getAttr: function(attr, val) {
47         var el = this.target;
48         return [[ el, this.getElVal(el, attr, val)]];
49     },
50
51     setAttr: function(targetData) {
52         var target = this.target,
53             ln = targetData.length,
54             attrs, attr, o, i, j, ln2, element, value;
55         for (i = 0; i &lt; ln; i++) {
56             attrs = targetData[i].attrs;
57             for (attr in attrs) {
58                 if (attrs.hasOwnProperty(attr)) {
59                     ln2 = attrs[attr].length;
60                     for (j = 0; j &lt; ln2; j++) {
61                         o = attrs[attr][j];
62                         element = o[0];
63                         value = o[1];
64                         if (attr === 'x') {
65                             element.setX(value);
66                         }
67                         else if (attr === 'y') {
68                             element.setY(value);
69                         }
70                         else if (attr === 'scrollTop') {
71                             element.scrollTo('top', value);
72                         }
73                         else if (attr === 'scrollLeft') {
74                             element.scrollTo('left',value);
75                         }
76                         else {
77                             element.setStyle(attr, value);
78                         }
79                     }
80                 }
81             }
82         }
83     }
84 });
85 </pre></pre></body></html>