123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
- <title>The source code</title>
- <link href="../resources/prettify/prettify.css" type="text/css" rel="stylesheet" />
- <script type="text/javascript" src="../resources/prettify/prettify.js"></script>
- <style type="text/css">
- .highlight { display: block; background-color: #ddd; }
- </style>
- <script type="text/javascript">
- function highlight() {
- document.getElementById(location.hash.replace(/#/, "")).className = "highlight";
- }
- </script>
- </head>
- <body onload="prettyPrint(); highlight();">
- <pre class="prettyprint lang-js"><span id='Ext-fx-PropertyHandler'>/**
- </span> * @private
- */
- Ext.define('Ext.fx.PropertyHandler', {
- /* Begin Definitions */
- requires: ['Ext.draw.Draw'],
- statics: {
- defaultHandler: {
- pixelDefaultsRE: /width|height|top$|bottom$|left$|right$/i,
- unitRE: /^(-?\d*\.?\d*){1}(em|ex|px|in|cm|mm|pt|pc|%)*$/,
- scrollRE: /^scroll/i,
- computeDelta: function(from, end, damper, initial, attr) {
- damper = (typeof damper == 'number') ? damper : 1;
- var unitRE = this.unitRE,
- match = unitRE.exec(from),
- start, units;
- if (match) {
- from = match[1];
- units = match[2];
- if (!this.scrollRE.test(attr) && !units && this.pixelDefaultsRE.test(attr)) {
- units = 'px';
- }
- }
- from = +from || 0;
- match = unitRE.exec(end);
- if (match) {
- end = match[1];
- units = match[2] || units;
- }
- end = +end || 0;
- start = (initial != null) ? initial : from;
- return {
- from: from,
- delta: (end - start) * damper,
- units: units
- };
- },
- get: function(from, end, damper, initialFrom, attr) {
- var ln = from.length,
- out = [],
- i, initial, res, j, len;
- for (i = 0; i < ln; i++) {
- if (initialFrom) {
- initial = initialFrom[i][1].from;
- }
- if (Ext.isArray(from[i][1]) && Ext.isArray(end)) {
- res = [];
- j = 0;
- len = from[i][1].length;
- for (; j < len; j++) {
- res.push(this.computeDelta(from[i][1][j], end[j], damper, initial, attr));
- }
- out.push([from[i][0], res]);
- }
- else {
- out.push([from[i][0], this.computeDelta(from[i][1], end, damper, initial, attr)]);
- }
- }
- return out;
- },
- set: function(values, easing) {
- var ln = values.length,
- out = [],
- i, val, res, len, j;
- for (i = 0; i < ln; i++) {
- val = values[i][1];
- if (Ext.isArray(val)) {
- res = [];
- j = 0;
- len = val.length;
- for (; j < len; j++) {
- res.push(val[j].from + val[j].delta * easing + (val[j].units || 0));
- }
- out.push([values[i][0], res]);
- } else {
- out.push([values[i][0], val.from + val.delta * easing + (val.units || 0)]);
- }
- }
- return out;
- }
- },
- stringHandler: {
- computeDelta: function(from, end, damper, initial, attr) {
- return {
- from: from,
- delta: end
- };
- },
- get: function(from, end, damper, initialFrom, attr) {
- var ln = from.length,
- out = [],
- i, initial, res, j, len;
- for (i = 0; i < ln; i++) {
- out.push([from[i][0], this.computeDelta(from[i][1], end, damper, initial, attr)]);
- }
- return out;
- },
- set: function(values, easing) {
- var ln = values.length,
- out = [],
- i, val, res, len, j;
- for (i = 0; i < ln; i++) {
- val = values[i][1];
- out.push([values[i][0], val.delta]);
- }
- return out;
- }
- },
- color: {
- rgbRE: /^rgb\(([0-9]+)\s*,\s*([0-9]+)\s*,\s*([0-9]+)\)$/i,
- hexRE: /^#?([0-9A-F]{2})([0-9A-F]{2})([0-9A-F]{2})$/i,
- hex3RE: /^#?([0-9A-F]{1})([0-9A-F]{1})([0-9A-F]{1})$/i,
- parseColor : function(color, damper) {
- damper = (typeof damper == 'number') ? damper : 1;
- var out = false,
- reList = [this.hexRE, this.rgbRE, this.hex3RE],
- length = reList.length,
- match, base, re, i;
- for (i = 0; i < length; i++) {
- re = reList[i];
- base = (i % 2 === 0) ? 16 : 10;
- match = re.exec(color);
- if (match && match.length === 4) {
- if (i === 2) {
- match[1] += match[1];
- match[2] += match[2];
- match[3] += match[3];
- }
- out = {
- red: parseInt(match[1], base),
- green: parseInt(match[2], base),
- blue: parseInt(match[3], base)
- };
- break;
- }
- }
- return out || color;
- },
- computeDelta: function(from, end, damper, initial) {
- from = this.parseColor(from);
- end = this.parseColor(end, damper);
- var start = initial ? initial : from,
- tfrom = typeof start,
- tend = typeof end;
- //Extra check for when the color string is not recognized.
- if (tfrom == 'string' || tfrom == 'undefined'
- || tend == 'string' || tend == 'undefined') {
- return end || start;
- }
- return {
- from: from,
- delta: {
- red: Math.round((end.red - start.red) * damper),
- green: Math.round((end.green - start.green) * damper),
- blue: Math.round((end.blue - start.blue) * damper)
- }
- };
- },
- get: function(start, end, damper, initialFrom) {
- var ln = start.length,
- out = [],
- i, initial;
- for (i = 0; i < ln; i++) {
- if (initialFrom) {
- initial = initialFrom[i][1].from;
- }
- out.push([start[i][0], this.computeDelta(start[i][1], end, damper, initial)]);
- }
- return out;
- },
- set: function(values, easing) {
- var ln = values.length,
- out = [],
- i, val, parsedString, from, delta;
- for (i = 0; i < ln; i++) {
- val = values[i][1];
- if (val) {
- from = val.from;
- delta = val.delta;
- //multiple checks to reformat the color if it can't recognized by computeDelta.
- val = (typeof val == 'object' && 'red' in val)?
- 'rgb(' + val.red + ', ' + val.green + ', ' + val.blue + ')' : val;
- val = (typeof val == 'object' && val.length)? val[0] : val;
- if (typeof val == 'undefined') {
- return [];
- }
- parsedString = typeof val == 'string'? val :
- 'rgb(' + [
- (from.red + Math.round(delta.red * easing)) % 256,
- (from.green + Math.round(delta.green * easing)) % 256,
- (from.blue + Math.round(delta.blue * easing)) % 256
- ].join(',') + ')';
- out.push([
- values[i][0],
- parsedString
- ]);
- }
- }
- return out;
- }
- },
- object: {
- interpolate: function(prop, damper) {
- damper = (typeof damper == 'number') ? damper : 1;
- var out = {},
- p;
- for(p in prop) {
- out[p] = parseFloat(prop[p]) * damper;
- }
- return out;
- },
- computeDelta: function(from, end, damper, initial) {
- from = this.interpolate(from);
- end = this.interpolate(end, damper);
- var start = initial ? initial : from,
- delta = {},
- p;
- for(p in end) {
- delta[p] = end[p] - start[p];
- }
- return {
- from: from,
- delta: delta
- };
- },
- get: function(start, end, damper, initialFrom) {
- var ln = start.length,
- out = [],
- i, initial;
- for (i = 0; i < ln; i++) {
- if (initialFrom) {
- initial = initialFrom[i][1].from;
- }
- out.push([start[i][0], this.computeDelta(start[i][1], end, damper, initial)]);
- }
- return out;
- },
- set: function(values, easing) {
- var ln = values.length,
- out = [],
- outObject = {},
- i, from, delta, val, p;
- for (i = 0; i < ln; i++) {
- val = values[i][1];
- from = val.from;
- delta = val.delta;
- for (p in from) {
- outObject[p] = from[p] + delta[p] * easing;
- }
- out.push([
- values[i][0],
- outObject
- ]);
- }
- return out;
- }
- },
- path: {
- computeDelta: function(from, end, damper, initial) {
- damper = (typeof damper == 'number') ? damper : 1;
- var start;
- from = +from || 0;
- end = +end || 0;
- start = (initial != null) ? initial : from;
- return {
- from: from,
- delta: (end - start) * damper
- };
- },
- forcePath: function(path) {
- if (!Ext.isArray(path) && !Ext.isArray(path[0])) {
- path = Ext.draw.Draw.parsePathString(path);
- }
- return path;
- },
- get: function(start, end, damper, initialFrom) {
- var endPath = this.forcePath(end),
- out = [],
- startLn = start.length,
- startPathLn, pointsLn, i, deltaPath, initial, j, k, path, startPath;
- for (i = 0; i < startLn; i++) {
- startPath = this.forcePath(start[i][1]);
- deltaPath = Ext.draw.Draw.interpolatePaths(startPath, endPath);
- startPath = deltaPath[0];
- endPath = deltaPath[1];
- startPathLn = startPath.length;
- path = [];
- for (j = 0; j < startPathLn; j++) {
- deltaPath = [startPath[j][0]];
- pointsLn = startPath[j].length;
- for (k = 1; k < pointsLn; k++) {
- initial = initialFrom && initialFrom[0][1][j][k].from;
- deltaPath.push(this.computeDelta(startPath[j][k], endPath[j][k], damper, initial));
- }
- path.push(deltaPath);
- }
- out.push([start[i][0], path]);
- }
- return out;
- },
- set: function(values, easing) {
- var ln = values.length,
- out = [],
- i, j, k, newPath, calcPath, deltaPath, deltaPathLn, pointsLn;
- for (i = 0; i < ln; i++) {
- deltaPath = values[i][1];
- newPath = [];
- deltaPathLn = deltaPath.length;
- for (j = 0; j < deltaPathLn; j++) {
- calcPath = [deltaPath[j][0]];
- pointsLn = deltaPath[j].length;
- for (k = 1; k < pointsLn; k++) {
- calcPath.push(deltaPath[j][k].from + deltaPath[j][k].delta * easing);
- }
- newPath.push(calcPath.join(','));
- }
- out.push([values[i][0], newPath.join(',')]);
- }
- return out;
- }
- }
- /* End Definitions */
- }
- }, function() {
- //set color properties to color interpolator
- var props = [
- 'outlineColor',
- 'backgroundColor',
- 'borderColor',
- 'borderTopColor',
- 'borderRightColor',
- 'borderBottomColor',
- 'borderLeftColor',
- 'fill',
- 'stroke'
- ],
- length = props.length,
- i = 0,
- prop;
- for (; i<length; i++) {
- prop = props[i];
- this[prop] = this.color;
- }
-
- //set string properties to string
- props = ['cursor'];
- length = props.length;
- i = 0;
- for (; i<length; i++) {
- prop = props[i];
- this[prop] = this.stringHandler;
- }
- });
- </pre>
- </body>
- </html>
|