3 This file is part of Ext JS 4
5 Copyright (c) 2011 Sencha Inc
7 Contact: http://www.sencha.com/contact
9 GNU General Public License Usage
10 This file may be used under the terms of the GNU General Public License version 3.0 as published by the Free Software Foundation and appearing in the file LICENSE included in the packaging of this file. Please review the following information to ensure the GNU General Public License version 3.0 requirements will be met: http://www.gnu.org/copyleft/gpl.html.
12 If you are unsure which license is appropriate for your use, please contact the sales department at http://www.sencha.com/contact.
16 * @class Ext.fx.target.Sprite
17 * @extends Ext.fx.target.Target
19 This class represents a animation target for a {@link Ext.draw.Sprite}. In general this class will not be
20 created directly, the {@link Ext.draw.Sprite} will be passed to the animation and
21 and the appropriate target will be created.
26 Ext.define('Ext.fx.target.Sprite', {
28 /* Begin Definitions */
30 extend: 'Ext.fx.target.Target',
36 getFromPrim: function(sprite, attr) {
38 if (attr == 'translate') {
40 x: sprite.attr.translation.x || 0,
41 y: sprite.attr.translation.y || 0
44 else if (attr == 'rotate') {
46 degrees: sprite.attr.rotation.degrees || 0,
47 x: sprite.attr.rotation.x,
48 y: sprite.attr.rotation.y
52 o = sprite.attr[attr];
57 getAttr: function(attr, val) {
58 return [[this.target, val != undefined ? val : this.getFromPrim(this.target, attr)]];
61 setAttr: function(targetData) {
62 var ln = targetData.length,
64 attrs, attr, attrArr, attPtr, spritePtr, idx, value, i, j, x, y, ln2;
65 for (i = 0; i < ln; i++) {
66 attrs = targetData[i].attrs;
68 attrArr = attrs[attr];
70 for (j = 0; j < ln2; j++) {
71 spritePtr = attrArr[j][0];
72 attPtr = attrArr[j][1];
73 if (attr === 'translate') {
79 else if (attr === 'rotate') {
89 degrees: attPtr.degrees,
94 else if (attr === 'width' || attr === 'height' || attr === 'x' || attr === 'y') {
95 value = parseFloat(attPtr);
100 idx = Ext.Array.indexOf(spriteArr, spritePtr);
102 spriteArr.push([spritePtr, {}]);
103 idx = spriteArr.length - 1;
105 spriteArr[idx][1][attr] = value;
109 ln = spriteArr.length;
110 for (i = 0; i < ln; i++) {
111 spritePtr = spriteArr[i];
112 spritePtr[0].setAttributes(spritePtr[1]);
114 this.target.redraw();