4 <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
5 <title>The source code</title>
6 <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
7 <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
8 <style type="text/css">
9 .highlight { display: block; background-color: #ddd; }
11 <script type="text/javascript">
12 function highlight() {
13 document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
17 <body onload="prettyPrint(); highlight();">
18 <pre class="prettyprint lang-js"><span id='Ext-fx-PropertyHandler'>/**
19 </span> * @class Ext.fx.PropertyHandler
22 Ext.define('Ext.fx.PropertyHandler', {
24 /* Begin Definitions */
26 requires: ['Ext.draw.Draw'],
30 pixelDefaultsRE: /width|height|top$|bottom$|left$|right$/i,
31 unitRE: /^(-?\d*\.?\d*){1}(em|ex|px|in|cm|mm|pt|pc|%)*$/,
34 computeDelta: function(from, end, damper, initial, attr) {
35 damper = (typeof damper == 'number') ? damper : 1;
36 var unitRE = this.unitRE,
37 match = unitRE.exec(from),
42 if (!this.scrollRE.test(attr) && !units && this.pixelDefaultsRE.test(attr)) {
48 match = unitRE.exec(end);
51 units = match[2] || units;
54 start = (initial != null) ? initial : from;
57 delta: (end - start) * damper,
62 get: function(from, end, damper, initialFrom, attr) {
65 i, initial, res, j, len;
66 for (i = 0; i < ln; i++) {
68 initial = initialFrom[i][1].from;
70 if (Ext.isArray(from[i][1]) && Ext.isArray(end)) {
73 len = from[i][1].length;
74 for (; j < len; j++) {
75 res.push(this.computeDelta(from[i][1][j], end[j], damper, initial, attr));
77 out.push([from[i][0], res]);
80 out.push([from[i][0], this.computeDelta(from[i][1], end, damper, initial, attr)]);
86 set: function(values, easing) {
87 var ln = values.length,
90 for (i = 0; i < ln; i++) {
92 if (Ext.isArray(val)) {
96 for (; j < len; j++) {
97 res.push(val[j].from + (val[j].delta * easing) + (val[j].units || 0));
99 out.push([values[i][0], res]);
101 out.push([values[i][0], val.from + (val.delta * easing) + (val.units || 0)]);
108 rgbRE: /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i,
109 hexRE: /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i,
110 hex3RE: /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i,
112 parseColor : function(color, damper) {
113 damper = (typeof damper == 'number') ? damper : 1;
118 Ext.each([this.hexRE, this.rgbRE, this.hex3RE], function(re, idx) {
119 base = (idx % 2 == 0) ? 16 : 10;
120 match = re.exec(color);
121 if (match && match.length == 4) {
123 match[1] += match[1];
124 match[2] += match[2];
125 match[3] += match[3];
128 red: parseInt(match[1], base),
129 green: parseInt(match[2], base),
130 blue: parseInt(match[3], base)
138 computeDelta: function(from, end, damper, initial) {
139 from = this.parseColor(from);
140 end = this.parseColor(end, damper);
141 var start = initial ? initial : from,
142 tfrom = typeof start,
144 //Extra check for when the color string is not recognized.
145 if (tfrom == 'string' || tfrom == 'undefined'
146 || tend == 'string' || tend == 'undefined') {
152 red: Math.round((end.red - start.red) * damper),
153 green: Math.round((end.green - start.green) * damper),
154 blue: Math.round((end.blue - start.blue) * damper)
159 get: function(start, end, damper, initialFrom) {
160 var ln = start.length,
163 for (i = 0; i < ln; i++) {
165 initial = initialFrom[i][1].from;
167 out.push([start[i][0], this.computeDelta(start[i][1], end, damper, initial)]);
172 set: function(values, easing) {
173 var ln = values.length,
175 i, val, parsedString, from, delta;
176 for (i = 0; i < ln; i++) {
181 //multiple checks to reformat the color if it can't recognized by computeDelta.
182 val = (typeof val == 'object' && 'red' in val)?
183 'rgb(' + val.red + ', ' + val.green + ', ' + val.blue + ')' : val;
184 val = (typeof val == 'object' && val.length)? val[0] : val;
185 if (typeof val == 'undefined') {
188 parsedString = typeof val == 'string'? val :
190 (from.red + Math.round(delta.red * easing)) % 256,
191 (from.green + Math.round(delta.green * easing)) % 256,
192 (from.blue + Math.round(delta.blue * easing)) % 256
204 interpolate: function(prop, damper) {
205 damper = (typeof damper == 'number') ? damper : 1;
209 out[p] = parseInt(prop[p], 10) * damper;
214 computeDelta: function(from, end, damper, initial) {
215 from = this.interpolate(from);
216 end = this.interpolate(end, damper);
217 var start = initial ? initial : from,
222 delta[p] = end[p] - start[p];
230 get: function(start, end, damper, initialFrom) {
231 var ln = start.length,
234 for (i = 0; i < ln; i++) {
236 initial = initialFrom[i][1].from;
238 out.push([start[i][0], this.computeDelta(start[i][1], end, damper, initial)]);
243 set: function(values, easing) {
244 var ln = values.length,
247 i, from, delta, val, p;
248 for (i = 0; i < ln; i++) {
253 outObject[p] = Math.round(from[p] + delta[p] * easing);
265 computeDelta: function(from, end, damper, initial) {
266 damper = (typeof damper == 'number') ? damper : 1;
270 start = (initial != null) ? initial : from;
273 delta: (end - start) * damper
277 forcePath: function(path) {
278 if (!Ext.isArray(path) && !Ext.isArray(path[0])) {
279 path = Ext.draw.Draw.parsePathString(path);
284 get: function(start, end, damper, initialFrom) {
285 var endPath = this.forcePath(end),
287 startLn = start.length,
288 startPathLn, pointsLn, i, deltaPath, initial, j, k, path, startPath;
289 for (i = 0; i < startLn; i++) {
290 startPath = this.forcePath(start[i][1]);
292 deltaPath = Ext.draw.Draw.interpolatePaths(startPath, endPath);
293 startPath = deltaPath[0];
294 endPath = deltaPath[1];
296 startPathLn = startPath.length;
298 for (j = 0; j < startPathLn; j++) {
299 deltaPath = [startPath[j][0]];
300 pointsLn = startPath[j].length;
301 for (k = 1; k < pointsLn; k++) {
302 initial = initialFrom && initialFrom[0][1][j][k].from;
303 deltaPath.push(this.computeDelta(startPath[j][k], endPath[j][k], damper, initial));
305 path.push(deltaPath);
307 out.push([start[i][0], path]);
312 set: function(values, easing) {
313 var ln = values.length,
315 i, j, k, newPath, calcPath, deltaPath, deltaPathLn, pointsLn;
316 for (i = 0; i < ln; i++) {
317 deltaPath = values[i][1];
319 deltaPathLn = deltaPath.length;
320 for (j = 0; j < deltaPathLn; j++) {
321 calcPath = [deltaPath[j][0]];
322 pointsLn = deltaPath[j].length;
323 for (k = 1; k < pointsLn; k++) {
324 calcPath.push(deltaPath[j][k].from + deltaPath[j][k].delta * easing);
326 newPath.push(calcPath.join(','));
328 out.push([values[i][0], newPath.join(',')]);
333 /* End Definitions */
347 this[prop] = this.color;