Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

making JS Lint changes

  • Loading branch information...
commit e5992446d632d890721f60ddd0447dec04a91ade 1 parent 08dffa7
@heygrady authored
View
467 dist/jquery.transform-0.9.0pre.js
@@ -6,7 +6,7 @@
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
- * Date: Wed Oct 6 23:16:32 2010 -0700
+ * Date: Sun Oct 24 22:50:33 2010 -0700
*/
///////////////////////////////////////////////////////
// Transform
@@ -576,7 +576,7 @@
var rfuncvalue = /([\w\-]*?)\((.*?)\)/g, // with values
attr = 'data-transform',
rspace = /\s/,
- rcspace = /,\s/;
+ rcspace = /,\s?/;
$.extend($.transform.prototype, {
/**
@@ -609,13 +609,12 @@
if ($.isArray(value)) {
value = value.join(', ');
}
- value = $.trim(value+'');
// pull from a local variable to look it up
var transform = this.attr || this.$elem.attr(attr);
if (!transform || transform.indexOf(func) > -1) {
- // We don't have any existing values, save it
+ // we don't have any existing values, save it
// we don't have this function yet, save it
this.attr = $.trim(transform + ' ' + func + '(' + value + ')');
this.$elem.attr(attr, this.attr);
@@ -666,46 +665,93 @@
*/
getAttr: function(func) {
var attrs = this.getAttrs();
-
if (typeof attrs[func] !== 'undefined') {
return attrs[func];
}
- // animate needs sensible defaults for some props
- switch (func) {
- case 'scale': return [1, 1];
- case 'scaleX': // no break;
- case 'scaleY': return 1;
- case 'matrix': return [1, 0, 0, 1, 0, 0];
- case 'origin':
- if ($.support.csstransforms) {
- // supported browsers return percentages always
- return this.$elem.css(this.transformOriginProperty).split(rspace);
- } else {
- // just force IE to also return a percentage
- return ['50%', '50%'];
- }
+ //TODO: move the origin to a function
+ if (func === 'origin' && $.support.csstransforms) {
+ // supported browsers return percentages always
+ return this.$elem.css(this.transformOriginProperty).split(rspace);
+ } else if (func === 'origin') {
+ // just force IE to also return a percentage
+ return ['50%', '50%'];
}
- return null;
+
+ return $.cssDefault[func] || 0;
}
});
+
+ // Define default values
+ if (typeof($.cssDefault) == 'undefined') {
+ $.cssDefault = {};
+ }
+ $.cssDefault.scale = [1, 1];
+ $.cssDefault.scaleX = 1;
+ $.cssDefault.scaleY = 1;
+ $.cssDefault.matrix = [1, 0, 0, 1, 0, 0];
+ $.cssDefault.origin = ['50%', '50%']; // TODO: allow this to be a function, like get
+
+ $.cssDefault.reflect = [1, 0, 0, 1, 0, 0];
+ $.cssDefault.reflectX = [1, 0, 0, 1, 0, 0];
+ $.cssDefault.reflectXY = [1, 0, 0, 1, 0, 0];
+ $.cssDefault.reflectY = [1, 0, 0, 1, 0, 0];
+
+ // Define functons with multiple values
+ if (typeof($.cssMultipleValues) == 'undefined') {
+ $.cssMultipleValues = {};
+ }
+ $.extend($.cssMultipleValues, {
+ matrix: 6,
+
+ reflect: 6,
+ reflectX: 6,
+ reflectXY: 6,
+ reflectY: 6,
+
+ scale: {
+ length: 2,
+ duplicate: true
+ },
+ skew: 2,
+ translate: 2
+ });
+
+ // override all of the css functions
+ $.each($.transform.funcs, function(i, func) {
+ $.cssNumber[func] = true;
+ $.cssHooks[func] = {
+ set: function(elem, value) {
+ var transform = elem.transform || new $.transform(elem),
+ funcs = {};
+ funcs[func] = value;
+ transform.exec(funcs, {preserve: true});
+ },
+ get: function(elem, computed) {
+ var transform = elem.transform || new $.transform(elem);
+ return transform.getAttr(func);
+ }
+ };
+ });
+
+ // Support Reflection animation better by returning a matrix
+ $.each(['reflect', 'reflectX', 'reflectXY', 'reflectY'], function(i, func) {
+ $.cssHooks[func].get = function(elem, computed) {
+ var transform = elem.transform || new $.transform(elem);
+ return transform.getAttr('matrix') || $.cssDefault[func];
+ };
+ });
})(jQuery, this, this.document);
///////////////////////////////////////////////////////
// Animation
///////////////////////////////////////////////////////
(function($, window, document, undefined) {
- // Extend the jQuery animation to handle transform functions
/**
* @var Regex looks for units on a string
*/
var rfxnum = /^([+\-]=)?([\d+.\-]+)(.*)$/;
/**
- * @var Regex identify if additional values are hidden in the unit
- */
- var rfxmultinum = /^(.*?)\s+([+\-]=)?([\d+.\-]+)(.*)$/;
-
- /**
* Doctors prop values in the event that they contain spaces
* @param Object prop
* @param String speed
@@ -715,197 +761,112 @@
*/
var _animate = $.fn.animate;
$.fn.animate = function( prop, speed, easing, callback ) {
- //NOTE: The $.fn.animate() function is a big jerk and requires
- // you to attempt to convert the values passed into pixels.
- // So we have to doctor the values passed in here to make
- // sure $.fn.animate() won't think there's units an ruin
- // our fun.
- if (prop && !jQuery.isEmptyObject(prop)) {
- var $elem = this;
+ var optall = jQuery.speed(speed, easing, callback);
+
+ // Capture multiple values
+ if (!jQuery.isEmptyObject(prop)) {
jQuery.each( prop, function( name, val ) {
- // Clean up the numbers for space-sperated prop values
- if ($.inArray(name, $.transform.funcs) != -1) {
- // allow for reflection animation
- if ($.transform.rfunc.reflect.test(name)) {
- var m = val ? $.matrix[name]() : $.matrix.identity(),
- e = m.elements;
- val = [e[0], e[1], e[2], e[3]];
+ if ($.cssMultipleValues[name]) {
+ if (typeof optall.multiple === 'undefined') {
+ optall.multiple = {};
}
-
- var parts = rfxnum.exec(val);
- if ((parts && parts[3]) || $.isArray(val)) {
- // Either a unit was found or an array was passed
- var end, unit, values = [];
-
- if ($.isArray(val)) {
- // An array was passed
- $.each(val, function(i) {
- parts = rfxnum.exec(this);
- end = parseFloat(parts[2]);
- unit = parts[3] || "px";
-
- // Remember value
- values.push({
- end: (parts[1] ? parts[1] : '') + end,
- unit: unit
- });
- });
- } else {
- // A unit was found
- end = parseFloat( parts[2] );
- unit = parts[3] || "px";
-
- // Remember the first value
- values.push({
- end: (parts[1] ? parts[1] : '') + end,
- unit: unit
- });
-
- // Detect additional values hidden in the unit
- var i = 0;
- while (parts = rfxmultinum.exec(unit)) {
- // Fix the previous unit
- values[i].unit = parts[1];
-
- // Remember this value
- values.push({
- end: (parts[2] ? parts[2] : '') + parseFloat(parts[3]),
- unit: parts[4]
- });
- unit = parts[4];
- i++;
- }
- }
+ // force the original values onto the optall
+ optall.multiple[name] = val.toString();
- // Save the values and truncate the value to make it safe to animate
- $elem.data('data-animate-' + name, values);
- prop[name] = values[0].end; // NOTE: this propegates into the arguments object
- }
+ // reduce to a unitless number
+ prop[name] = parseFloat(val);
}
- });
+ } );
}
- //NOTE: we edit prop above
- return _animate.apply(this, arguments);
+
+ //NOTE: we edited prop above to trick animate
+ return _animate.apply(this, [arguments[0], optall]);
};
- /**
- * Returns appropriate start value for transform props
- * @param Boolean force
- * @return Number
- */
- var _cur = $.fx.prototype.cur;
- $.fx.prototype.cur = function(force) {
- //NOTE: The cur function tries to look things up on the element
- // itself as a native property first instead of as a style
- // property. However, the animate function is a big jerk
- // and it's extremely easy to poison the element.style
- // with a random property and ruin all of the fun. So, it's
- // easier to just look it up ourselves.
- if ($.inArray(this.prop, $.transform.funcs) != -1) {
- this.transform = this.transform || this.elem.transform || new $.transform(this.elem);
- var r = $.transform.rfunc;
-
- // return a single unitless number and animation will play nice
- var value = this.transform.getAttr(this.prop),
- parts = rfxnum.exec($.isArray(value) ? value[0] : value);
- if (value === null || parts === null) {
- value = r.scale.test(this.prop) || r.reflect.test(this.prop) ? 1 : 0;
- parts = [null, null, value];
+ var _custom = $.fx.prototype.custom;
+ $.fx.prototype.custom = function() {
+ var multiple = $.cssMultipleValues[this.prop];
+ if (multiple) {
+ this.values = [];
+
+ // Pull out the known values
+ var values = this.options.multiple[this.prop],
+ currentValues = $(this.elem).css(this.prop),
+ defaultValues = $.cssDefault[this.prop] || 0;
+
+ // make sure the current css value is an array
+ if (!$.isArray(currentValues)) {
+ currentValues = [currentValues];
}
- return parseFloat(parts[2]);
- }
- return _cur.apply(this, arguments);
- };
-
- /**
- * Detects the existence of a space separated value
- * @param Object fx
- * @return null
- */
- $.fx.multivalueInit = function(fx) {
- var $elem = $(fx.elem),
- values = fx.transform.getAttr(fx.prop), // existing values
- initValues = $elem.data('data-animate-' + fx.prop); // new values passed into animate
-
- if (initValues) {
- $elem.removeData('data-animate-' + fx.prop); // unremember the saved property
- }
-
- if ($.transform.rfunc.reflect.test(fx.prop)) {
- values = fx.transform.getAttr('matrix');
- }
-
- fx.values = [];
-
- // If we found a previous array but we're only setting one value, we need to set both
- if ($.isArray(values) && !$.isArray(initValues)) {
- initValues = [
- {
- end: parseFloat(fx.end),
- unit: fx.unit
- },
- {
- end: $.transform.rfunc.scale.test(fx.prop) ? 1 : 0,
- unit: fx.unit
- }
- ];
- }
-
- // If we altered the values before
- // This happens in the doctored animate function when we pass a unit or multiple values
- if (initValues) {
- var start,
- rscalefunc = $.transform.rfunc.scale,
- parts;
- $.each(initValues, function(i, val) {
- // pull out the start value
- if ($.isArray(values)) {
- start = values[i];
- } else if (i > 0) {
- // scale duplicates the values for x and y
- start = rscalefunc.test(fx.prop) ? values : null;
+
+ // make sure the new values are an array
+ if (!$.isArray(values)) {
+ if ($.type(values) === 'string') {
+ values = values.split(',');
} else {
- start = values;
+ values = [values];
}
-
- // if we didn't find a start value
- if (!start && start !== 0) {
- start = rscalefunc.test(fx.prop) ? 1 : 0;
+ }
+
+ // make sure we have enough new values
+ var length = multiple.length || multiple, i = 0;
+ while (values.length < length) {
+ values.push(multiple.duplicate ? values[0] : defaultValues[i] || 0);
+ i++;
+ }
+
+ // calculate a start, end and unit for each new value
+ var start, parts, end, unit, fx = this;
+
+ $.each(values, function(i, val) {
+ // find a sensible start value
+ if (currentValues[i]) {
+ start = currentValues[i];
+ } else if (defaultValues[i] && !multiple.duplicate) {
+ start = defaultValues[i];
+ } else if (multiple.duplicate) {
+ start = currentValues[0];
+ } else {
+ start = 0;
}
-
- // ensure a number
start = parseFloat(start);
- // handle the existence of += and -= prefixes
- parts = rfxnum.exec(val.end);
- if (parts && parts[1]) {
- val.end = ((parts[1] === "-=" ? -1 : 1) * parseFloat(parts[2])) + start;
+ // parse the value with a regex
+ parts = rfxnum.exec(val);
+
+ if (parts) {
+ // we found a sensible value and unit
+ end = parseFloat( parts[2] );
+ unit = parts[3] || "px"; //TODO: change to an appropriate default unit
+
+ // If a +=/-= token was provided, we're doing a relative animation
+ if (parts[1]) {
+ end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
+ }
+ } else {
+ // I don't know when this would happen
+ end = val;
+ unit = '';
}
// Save the values
fx.values.push({
- start: parseFloat(start),
- end: parseFloat(val.end),
- unit: val.unit
- });
- });
- } else {
- // Save the known value
- fx.values.push({
- start: parseFloat(fx.start),
- end: parseFloat(fx.end), // force a Number
- unit: fx.unit
+ start: start,
+ end: end,
+ unit: unit
+ });
});
}
+ return _custom.apply(this, arguments);
};
-
+
/**
* Animates a multi value attribute
* @param Object fx
* @return null
*/
- $.fx.multivalueStep = {
+ $.fx.multipleValueStep = {
_default: function(fx) {
$.each(fx.values, function(i, val) {
fx.values[i].now = val.start + ((val.end - val.start) * fx.pos);
@@ -918,72 +879,56 @@
*/
$.each($.transform.funcs, function(i, func) {
$.fx.step[func] = function(fx) {
- // Initialize the transformation
- if (!fx.transformInit) {
- fx.transform = fx.transform || fx.elem.transform || new $.transform(fx.elem);
-
- // Handle multiple values
- $.fx.multivalueInit(fx);
- if (fx.values.length > 1) {
- fx.multiple = true;
- }
-
- // Force degrees for angles, Remove units for unitless
- var r = $.transform.rfunc;
- if (r.angle.test(fx.prop)) {
- //TODO: we should convert from other rational units
- fx.unit = 'deg';
- } else if (r.scale.test(fx.prop)) {
- fx.unit = '';
- } else if (r.reflect.test(fx.prop)) {
- //TODO: for animation purposes, this is a matrix and can be animated (although it looks silly)
- fx.unit = ''; //this is a boolean func
- } else if (fx.prop == 'matrix') {
- fx.unit = '';
- }
- //TODO: I guess we already foced length units earlier
-
- // Force all units on multiple values to be the same
- //TODO: we should convert from other rational units
- $.each(fx.values, function(i) {fx.values[i].unit = fx.unit;});
-
- fx.transformInit = true;
- }
-
-
- // Increment all of the values
- if (fx.multiple) {
- ($.fx.multivalueStep[fx.prop] || $.fx.multivalueStep._default)(fx);
+ var transform = fx.elem.transform || new $.transform(fx.elem),
+ funcs = {};
+
+ if ($.cssMultipleValues[func]) {
+ ($.fx.multipleValueStep[fx.prop] || $.fx.multipleValueStep._default)(fx);
+ funcs[fx.prop] = [];
+ $.each(fx.values, function(i, val) {
+ funcs[fx.prop].push(val.now);
+ });
} else {
- fx.values[0].now = fx.now;
+ funcs[fx.prop] = fx.now;
}
- var values = [];
-
- // Do some value correction and join the values
- $.each(fx.values, function(i, value) {
- // Keep angles below 360 in either direction.
- if (value.unit == 'deg') {
- while (value.now >= 360 ) {
- value.now -= 360;
- }
- while (value.now <= -360 ) {
- value.now += 360;
- }
- }
- // TODO: handle reflection matrices here
+ transform.exec(funcs, {preserve: true});
+ };
+ });
+
+ // Support Reflection animation
+ $.each(['reflect', 'reflectX', 'reflectXY', 'reflectY'], function(i, func) {
+ var _step = $.fx.step[func];
+ $.fx.step[func] = function(fx) {
+ var transform = fx.elem.transform || new $.transform(fx.elem),
+ funcs = {};
+
+ if (!fx.initialized) {
+ fx.start =
+ fx.initialized = true;
+ var values = $.matrix[func]().elements;
- //Pretty up the final value (use the double parseFloat
- // to correct super small decimals)
- values.push(parseFloat(parseFloat(value.now).toFixed(8)) + value.unit);
+ $.each(fx.values, function(i) {
+ var val;
+ switch (i) {
+ case 0: val = values[0]; break;
+ case 1: val = values[2]; break;
+ case 2: val = values[1]; break;
+ case 3: val = values[3]; break;
+ default: val = 0;
+ }
+ fx.values[i].end = val;
+ fx.initialized = true;
+ });
+ }
+
+ ($.fx.multipleValueStep[fx.prop] || $.fx.multipleValueStep._default)(fx);
+ funcs.matrix = [];
+ $.each(fx.values, function(i, val) {
+ funcs.matrix.push(val.now);
});
- // Apply the transformation
- var funcs = {},
- prop = $.transform.rfunc.reflect.test(fx.prop) ? 'matrix' : fx.prop;
-
- funcs[prop] = fx.multiple ? values : values[0];
- fx.transform.exec(funcs, {preserve: true});
+ transform.exec(funcs, {preserve: true});
};
});
})(jQuery, this, this.document);
@@ -1767,6 +1712,26 @@
0, 1, ty,
0, 0, 1
);
+ },
+
+ /**
+ * Translate on the X-axis
+ * @param Number tx
+ * @return Matrix
+ * @link http://www.w3.org/TR/SVG/coords.html#TranslationDefined
+ */
+ translateX: function (tx) {
+ return $.matrix.translate(tx);
+ },
+
+ /**
+ * Translate on the Y-axis
+ * @param Number ty
+ * @return Matrix
+ * @link http://www.w3.org/TR/SVG/coords.html#TranslationDefined
+ */
+ translateY: function (ty) {
+ return $.matrix.translate(0, ty);
}
});
})(jQuery, this, this.document);
View
4 dist/jquery.transform-0.9.0pre.min.js
@@ -6,6 +6,6 @@
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
- * Date: Wed Oct 6 23:16:32 2010 -0700
+ * Date: Sun Oct 24 22:50:33 2010 -0700
*/
-(function(g,h,k,c){var i=/progid:DXImageTransform\.Microsoft\.Matrix\(.*?\)/;var d=k.createElement("modernizr"),e=d.style;function o(m){return parseFloat(m)}function n(){var m={transformProperty:"",MozTransform:"-moz-",WebkitTransform:"-webkit-",OTransform:"-o-",msTransform:"-ms-"};for(var q in m){if(typeof e[q]!="undefined"){return m[q]}}return null}function p(){if(typeof(h.Modernizr)!=="undefined"){return Modernizr.csstransforms}var q=["transformProperty","WebkitTransform","MozTransform","OTransform","msTransform"];for(var m in q){if(e[q[m]]!==c){return true}}}var a=n(),j=a!==null?a+"transform":false,l=a!==null?a+"transform-origin":false;g.support.csstransforms=p();g.extend({transform:function(m){m.transform=this;this.$elem=g(m);this.applyingMatrix=false;this.matrix=null;this.height=null;this.width=null;this.outerHeight=null;this.outerWidth=null;this.boxSizingValue=null;this.boxSizingProperty=null;this.attr=null;this.transformProperty=j;this.transformOriginProperty=l}});g.extend(g.transform,{funcs:["matrix","origin","reflect","reflectX","reflectXY","reflectY","rotate","scale","scaleX","scaleY","skew","skewX","skewY","translate","translateX","translateY"],rfunc:{angle:/^rotate|skew[X|Y]?$/,length:/^origin|translate[X|Y]?$/,scale:/^scale[X|Y]?$/,reflect:/^reflect(XY|X|Y)?$/}});g.fn.transform=function(m,q){return this.each(function(){var r=this.transform||new g.transform(this);if(m){r.exec(m,q)}})};g.transform.prototype={exec:function(m,q){q=g.extend(true,{forceMatrix:false,preserve:false},q);this.attr=null;if(q.preserve){m=g.extend(true,this.getAttrs(true,true),m)}else{m=g.extend(true,{},m)}this.setAttrs(m);if(g.support.csstransforms&&!q.forceMatrix){return this.execFuncs(m)}else{if(g.browser.msie||(g.support.csstransforms&&q.forceMatrix)){return this.execMatrix(m)}}return false},execFuncs:function(q){var m=[];for(var r in q){if(r=="origin"){this[r].apply(this,g.isArray(q[r])?q[r]:[q[r]])}else{if(g.inArray(r,g.transform.funcs)!=-1){m.push(this.createTransformFunc(r,q[r]))}}}this.$elem.css(j,m.join(" "));return true},execMatrix:function(r){var C,x,z;for(var t in r){if(g.matrix[t]){z=g.isArray(r[t])?r[t]:[r[t]];z=g.map(z,o);x=g.matrix[t].apply(this,z);C=C?C.x(x):x}else{if(t=="origin"){z=g.isArray(r[t])?r[t]:[r[t]];this[t].apply(this,z)}}}C=C||g.matrix.identity();var D=parseFloat(C.e(1,1).toFixed(6)),B=parseFloat(C.e(2,1).toFixed(6)),A=parseFloat(C.e(1,2).toFixed(6)),y=parseFloat(C.e(2,2).toFixed(6)),v=C.rows===3?parseFloat(C.e(1,3).toFixed(6)):0,u=C.rows===3?parseFloat(C.e(2,3).toFixed(6)):0;if(g.support.csstransforms&&a==="-moz-"){this.$elem.css(j,"matrix("+D+", "+B+", "+A+", "+y+", "+v+"px, "+u+"px)")}else{if(g.support.csstransforms){this.$elem.css(j,"matrix("+D+", "+B+", "+A+", "+y+", "+v+", "+u+")")}else{if(g.browser.msie){var m=", FilterType='nearest neighbor'";var q=this.$elem[0].style;var w="progid:DXImageTransform.Microsoft.Matrix(M11="+D+", M12="+A+", M21="+B+", M22="+y+", sizingMethod='auto expand'"+m+")";var s=q.filter||jQuery.curCSS(this.$elem[0],"filter")||"";q.filter=i.test(s)?s.replace(i,w):s?s+" "+w:w;this.applyingMatrix=true;this.matrix=C;this.fixPosition(C,v,u);this.applyingMatrix=false;this.matrix=null}}}return true},origin:function(m,q){if(g.support.csstransforms){if(typeof q==="undefined"){this.$elem.css(l,m)}else{this.$elem.css(l,m+" "+q)}return true}switch(m){case"left":m="0";break;case"right":m="100%";break;case"center":case c:m="50%"}switch(q){case"top":q="0";break;case"bottom":q="100%";break;case"center":case c:q="50%"}if(/%/.test(m)&&/%/.test(q)){this.setAttr("origin",[m,q]);return true}this.setAttr("origin",[/%/.test(m)?m:parseFloat(m)+"px",/%/.test(q)?q:parseFloat(q)+"px"]);return true},createTransformFunc:function(s,t){if(g.transform.rfunc.reflect.test(s)){var r=t?g.matrix[s]():g.matrix.identity(),q=r.e(1,1),m=r.e(2,1),v=r.e(1,2),u=r.e(2,2);return"matrix("+q+", "+m+", "+v+", "+u+", 0, 0)"}t=f(s,t);if(!g.isArray(t)){return s+"("+t+")"}else{if(s=="matrix"){if(a==="-moz-"&&t[4]){t[4]=t[4]+"px"}if(a==="-moz-"&&t[5]){t[5]=t[5]+"px"}return"matrix("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+(t[4]||0)+", "+(t[5]||0)+")"}else{return s+"("+t[0]+", "+t[1]+")"}}},fixPosition:function(y,v,u,A,m){var t=new g.matrix.calc(y,this.safeOuterHeight(),this.safeOuterWidth()),z=this.getAttr("origin");var s=t.originOffset(new g.matrix.V2(/%/.test(z[0])?parseFloat(z[0])/100*t.outerWidth:parseFloat(z[0]),/%/.test(z[1])?parseFloat(z[1])/100*t.outerHeight:parseFloat(z[1])));var q=t.sides();var r=this.$elem.css("position");if(r=="static"){r="relative"}var x={top:0,left:0};var w={position:r,top:(s.top+u+q.top+x.top)+"px",left:(s.left+v+q.left+x.left)+"px",zoom:1};this.$elem.css(w)}};var b=/^([\+\-]=)?([\d+.\-]+)(.*)$/;function f(q,v){var x=!g.isArray(v)?[v]:v,m=g.transform.rfunc.angle,w=g.transform.rfunc.length;for(var s=0,t=x.length;s<t;s++){var r=b.exec(x[s]),u="";if(m.test(q)){u="deg";if(r[3]&&!g.angle.runit.test(r[3])){r[3]=null}}else{if(w.test(q)){u="px"}}if(!r){x[s]=0+u}else{if(!r[3]){x[s]+=u}}}return t==1?x[0]:x}})(jQuery,this,this.document);(function(d,c,a,f){d.extend(d.transform.prototype,{safeOuterHeight:function(){return this.safeOuterLength("height")},safeOuterWidth:function(){return this.safeOuterLength("width")},safeOuterLength:function(l){var o="outer"+(l=="width"?"Width":"Height");if(d.browser.msie){l=l=="width"?"width":"height";if(this.applyingMatrix&&!this[o]&&this.matrix){var k=new d.matrix.calc(this.matrix,1,1),m=k.offset(),g=this.$elem[o]()/m[l];this[o]=g;return g}else{if(this.applyingMatrix&&this[o]){return this[o]}}var n={height:["top","bottom"],width:["left","right"]};var h=this.$elem[0],j=parseFloat(d.curCSS(h,l,true)),p=this.boxSizingProperty,i=this.boxSizingValue;if(!this.boxSizingProperty){p=this.boxSizingProperty=e()||"box-sizing";i=this.boxSizingValue=this.$elem.css(p)||"content-box"}if(this[o]&&this[l]==j){return this[o]}else{this[l]=j}if(p&&(i=="padding-box"||i=="content-box")){j+=parseFloat(d.curCSS(h,"padding-"+n[l][0],true))||0+parseFloat(d.curCSS(h,"padding-"+n[l][1],true))||0}if(p&&i=="content-box"){j+=parseFloat(d.curCSS(h,"border-"+n[l][0]+"-width",true))||0+parseFloat(d.curCSS(h,"border-"+n[l][1]+"-width",true))||0}this[o]=j;return j}return this.$elem[o]()}});var b=null;function e(){if(b){return b}var h={boxSizing:"box-sizing",MozBoxSizing:"-moz-box-sizing",WebkitBoxSizing:"-webkit-box-sizing",OBoxSizing:"-o-box-sizing"},g=a.body;for(var i in h){if(typeof g.style[i]!="undefined"){b=h[i];return b}}return null}})(jQuery,this,this.document);(function(g,f,b,h){var d=/([\w\-]*?)\((.*?)\)/g,a="data-transform",e=/\s/,c=/,\s/;g.extend(g.transform.prototype,{setAttrs:function(i){var j="",l;for(var k in i){l=i[k];if(g.isArray(l)){l=l.join(", ")}j+=" "+k+"("+l+")"}this.attr=g.trim(j);this.$elem.attr(a,this.attr)},setAttr:function(k,l){if(g.isArray(l)){l=l.join(", ")}l=g.trim(l+"");var j=this.attr||this.$elem.attr(a);if(!j||j.indexOf(k)>-1){this.attr=g.trim(j+" "+k+"("+l+")");this.$elem.attr(a,this.attr)}else{var i=[],m;d.lastIndex=0;while((result=d.exec(j))!==null){if(k==m[1]){i.push(k+"("+l+")")}else{i.push(m[0])}}this.attr=i.join(" ");this.$elem.attr(a,this.attr)}},getAttrs:function(){var j=this.attr||this.$elem.attr(a);if(!j){return{}}var i={},l,k;d.lastIndex=0;while((l=d.exec(j))!==null){if(l){k=l[2].split(c);i[l[1]]=k.length==1?k[0]:k}}return i},getAttr:function(j){var i=this.getAttrs();if(typeof i[j]!=="undefined"){return i[j]}switch(j){case"scale":return[1,1];case"scaleX":case"scaleY":return 1;case"matrix":return[1,0,0,1,0,0];case"origin":if(g.support.csstransforms){return this.$elem.css(this.transformOriginProperty).split(e)}else{return["50%","50%"]}}return null}})})(jQuery,this,this.document);(function(e,d,b,f){var a=/^([+\-]=)?([\d+.\-]+)(.*)$/;var c=/^(.*?)\s+([+\-]=)?([\d+.\-]+)(.*)$/;var h=e.fn.animate;e.fn.animate=function(m,j,l,k){if(m&&!jQuery.isEmptyObject(m)){var i=this;jQuery.each(m,function(n,o){if(e.inArray(n,e.transform.funcs)!=-1){if(e.transform.rfunc.reflect.test(n)){var p=o?e.matrix[n]():e.matrix.identity(),t=p.elements;o=[t[0],t[1],t[2],t[3]]}var r=a.exec(o);if((r&&r[3])||e.isArray(o)){var q,u,v=[];if(e.isArray(o)){e.each(o,function(w){r=a.exec(this);q=parseFloat(r[2]);u=r[3]||"px";v.push({end:(r[1]?r[1]:"")+q,unit:u})})}else{q=parseFloat(r[2]);u=r[3]||"px";v.push({end:(r[1]?r[1]:"")+q,unit:u});var s=0;while(r=c.exec(u)){v[s].unit=r[1];v.push({end:(r[2]?r[2]:"")+parseFloat(r[3]),unit:r[4]});u=r[4];s++}}i.data("data-animate-"+n,v);m[n]=v[0].end}}})}return h.apply(this,arguments)};var g=e.fx.prototype.cur;e.fx.prototype.cur=function(k){if(e.inArray(this.prop,e.transform.funcs)!=-1){this.transform=this.transform||this.elem.transform||new e.transform(this.elem);var i=e.transform.rfunc;var j=this.transform.getAttr(this.prop),l=a.exec(e.isArray(j)?j[0]:j);if(j===null||l===null){j=i.scale.test(this.prop)||i.reflect.test(this.prop)?1:0;l=[null,null,j]}return parseFloat(l[2])}return g.apply(this,arguments)};e.fx.multivalueInit=function(l){var j=e(l.elem),i=l.transform.getAttr(l.prop),k=j.data("data-animate-"+l.prop);if(k){j.removeData("data-animate-"+l.prop)}if(e.transform.rfunc.reflect.test(l.prop)){i=l.transform.getAttr("matrix")}l.values=[];if(e.isArray(i)&&!e.isArray(k)){k=[{end:parseFloat(l.end),unit:l.unit},{end:e.transform.rfunc.scale.test(l.prop)?1:0,unit:l.unit}]}if(k){var o,n=e.transform.rfunc.scale,m;e.each(k,function(p,q){if(e.isArray(i)){o=i[p]}else{if(p>0){o=n.test(l.prop)?i:null}else{o=i}}if(!o&&o!==0){o=n.test(l.prop)?1:0}o=parseFloat(o);m=a.exec(q.end);if(m&&m[1]){q.end=((m[1]==="-="?-1:1)*parseFloat(m[2]))+o}l.values.push({start:parseFloat(o),end:parseFloat(q.end),unit:q.unit})})}else{l.values.push({start:parseFloat(l.start),end:parseFloat(l.end),unit:l.unit})}};e.fx.multivalueStep={_default:function(i){e.each(i.values,function(j,k){i.values[j].now=k.start+((k.end-k.start)*i.pos)})}};e.each(e.transform.funcs,function(j,k){e.fx.step[k]=function(n){if(!n.transformInit){n.transform=n.transform||n.elem.transform||new e.transform(n.elem);e.fx.multivalueInit(n);if(n.values.length>1){n.multiple=true}var m=e.transform.rfunc;if(m.angle.test(n.prop)){n.unit="deg"}else{if(m.scale.test(n.prop)){n.unit=""}else{if(m.reflect.test(n.prop)){n.unit=""}else{if(n.prop=="matrix"){n.unit=""}}}}e.each(n.values,function(p){n.values[p].unit=n.unit});n.transformInit=true}if(n.multiple){(e.fx.multivalueStep[n.prop]||e.fx.multivalueStep._default)(n)}else{n.values[0].now=n.now}var l=[];e.each(n.values,function(p,q){if(q.unit=="deg"){while(q.now>=360){q.now-=360}while(q.now<=-360){q.now+=360}}l.push(parseFloat(parseFloat(q.now).toFixed(8))+q.unit)});var i={},o=e.transform.rfunc.reflect.test(n.prop)?"matrix":n.prop;i[o]=n.multiple?l:l[0];n.transform.exec(i,{preserve:true})}})})(jQuery,this,this.document);(function(f,g,i,b){var c=180/Math.PI;var j=200/Math.PI;var e=Math.PI/180;var d=2/1.8;var h=0.9;var a=Math.PI/200;f.extend({angle:{runit:/(deg|g?rad)/,radianToDegree:function(k){return k*c},radianToGrad:function(k){return k*j},degreeToRadian:function(k){return k*e},degreeToGrad:function(k){return k*d},gradToDegree:function(k){return k*h},gradToRadian:function(k){return k*a}}})})(jQuery,this,this.document);(function(e,d,b,f){if(typeof(e.matrix)=="undefined"){e.extend({matrix:{}})}e.extend(e.matrix,{V2:function(g,h){if(e.isArray(arguments[0])){this.elements=arguments[0].slice(0,2)}else{this.elements=[g,h]}this.length=2},V3:function(g,i,h){if(e.isArray(arguments[0])){this.elements=arguments[0].slice(0,3)}else{this.elements=[g,i,h]}this.length=3},M2x2:function(h,g,j,i){if(e.isArray(arguments[0])){this.elements=arguments[0].slice(0,4)}else{this.elements=Array.prototype.slice.call(arguments).slice(0,4)}this.rows=2;this.cols=2},M3x3:function(l,k,j,i,h,g,o,n,m){if(e.isArray(arguments[0])){this.elements=arguments[0].slice(0,9)}else{this.elements=Array.prototype.slice.call(arguments).slice(0,9)}this.rows=3;this.cols=3}});var c={e:function(j,g){var h=this.rows,i=this.cols;if(j>h||g>h||j<1||g<1){return 0}return this.elements[(j-1)*i+g-1]}};e.extend(e.matrix.M2x2.prototype,c,{toM3x3:function(){var g=this.elements;return new e.matrix.M3x3(g[0],g[1],0,g[2],g[3],0,0,0,1)},x:function(i){var j=typeof(i.rows)==="undefined";if(!j&&i.rows==3){return this.toM3x3().x(i)}var h=this.elements,g=i.elements;if(j&&g.length==2){return new e.matrix.V2(h[0]*g[0]+h[1]*g[1],h[2]*g[0]+h[3]*g[1])}else{if(g.length==h.length){return new e.matrix.M2x2(h[0]*g[0]+h[1]*g[2],h[0]*g[1]+h[1]*g[3],h[2]*g[0]+h[3]*g[2],h[2]*g[1]+h[3]*g[3])}}return false},inverse:function(){var h=1/this.determinant(),g=this.elements;return new e.matrix.M2x2(h*g[3],h*-g[1],h*-g[2],h*g[0])},determinant:function(){var g=this.elements;return g[0]*g[3]-g[1]*g[2]}});e.extend(e.matrix.M3x3.prototype,c,{x:function(i){var j=typeof(i.rows)==="undefined";if(!j&&i.rows<3){i=i.toM3x3()}var h=this.elements,g=i.elements;if(j&&g.length==3){return new e.matrix.V3(h[0]*g[0]+h[1]*g[1]+h[2]*g[2],h[3]*g[0]+h[4]*g[1]+h[5]*g[2],h[6]*g[0]+h[7]*g[1]+h[8]*g[2])}else{if(g.length==h.length){return new e.matrix.M3x3(h[0]*g[0]+h[1]*g[3]+h[2]*g[6],h[0]*g[1]+h[1]*g[4]+h[2]*g[7],h[0]*g[2]+h[1]*g[5]+h[2]*g[8],h[3]*g[0]+h[4]*g[3]+h[5]*g[6],h[3]*g[1]+h[4]*g[4]+h[5]*g[7],h[3]*g[2]+h[4]*g[5]+h[5]*g[8],h[6]*g[0]+h[7]*g[3]+h[8]*g[6],h[6]*g[1]+h[7]*g[4]+h[8]*g[7],h[6]*g[2]+h[7]*g[5]+h[8]*g[8])}}return false},inverse:function(){var h=1/this.determinant(),g=this.elements;return new e.matrix.M3x3(h*(g[8]*g[4]-g[7]*g[5]),h*(-(g[8]*g[1]-g[7]*g[2])),h*(g[5]*g[1]-g[4]*g[2]),h*(-(g[8]*g[3]-g[6]*g[5])),h*(g[8]*g[0]-g[6]*g[2]),h*(-(g[5]*g[0]-g[3]*g[2])),h*(g[7]*g[3]-g[6]*g[4]),h*(-(g[7]*g[0]-g[6]*g[1])),h*(g[4]*g[0]-g[3]*g[1]))},determinant:function(){var g=this.elements;return g[0]*(g[8]*g[4]-g[7]*g[5])-g[3]*(g[8]*g[1]-g[7]*g[2])+g[6]*(g[5]*g[1]-g[4]*g[2])}});var a={e:function(g){return this.elements[g-1]}};e.extend(e.matrix.V2.prototype,a);e.extend(e.matrix.V3.prototype,a)})(jQuery,this,this.document);(function(c,b,a,d){if(typeof(c.matrix)=="undefined"){c.extend({matrix:{}})}c.extend(c.matrix,{calc:function(e,f,g){this.matrix=e;this.outerHeight=f;this.outerWidth=g}});c.matrix.calc.prototype={coord:function(e,i,h){h=typeof(h)!=="undefined"?h:0;var g=this.matrix,f;switch(g.rows){case 2:f=g.x(new c.matrix.V2(e,i));break;case 3:f=g.x(new c.matrix.V3(e,i,h));break}return f},corners:function(e,h){var f=!(typeof(e)!=="undefined"||typeof(h)!=="undefined"),g;if(!this.c||!f){h=h||this.outerHeight;e=e||this.outerWidth;g={tl:this.coord(0,0),bl:this.coord(0,h),tr:this.coord(e,0),br:this.coord(e,h)}}else{g=this.c}if(f){this.c=g}return g},sides:function(e){var f=e||this.corners();return{top:Math.min(f.tl.e(2),f.tr.e(2),f.br.e(2),f.bl.e(2)),bottom:Math.max(f.tl.e(2),f.tr.e(2),f.br.e(2),f.bl.e(2)),left:Math.min(f.tl.e(1),f.tr.e(1),f.br.e(1),f.bl.e(1)),right:Math.max(f.tl.e(1),f.tr.e(1),f.br.e(1),f.bl.e(1))}},offset:function(e){var f=this.sides(e);return{height:Math.abs(f.bottom-f.top),width:Math.abs(f.right-f.left)}},area:function(e){var h=e||this.corners();var g={x:h.tr.e(1)-h.tl.e(1)+h.br.e(1)-h.bl.e(1),y:h.tr.e(2)-h.tl.e(2)+h.br.e(2)-h.bl.e(2)},f={x:h.bl.e(1)-h.tl.e(1)+h.br.e(1)-h.tr.e(1),y:h.bl.e(2)-h.tl.e(2)+h.br.e(2)-h.tr.e(2)};return 0.25*Math.abs(g.e(1)*f.e(2)-g.e(2)*f.e(1))},nonAffinity:function(){var f=this.sides(),g=f.top-f.bottom,e=f.left-f.right;return parseFloat(parseFloat(Math.abs((Math.pow(g,2)+Math.pow(e,2))/(f.top*f.bottom+f.left*f.right))).toFixed(8))},originOffset:function(h,g){h=h?h:new c.matrix.V2(this.outerWidth*0.5,this.outerHeight*0.5);g=g?g:new c.matrix.V2(0,0);var e=this.coord(h.e(1),h.e(2));var f=this.coord(g.e(1),g.e(2));return{top:(f.e(2)-g.e(2))-(e.e(2)-h.e(2)),left:(f.e(1)-g.e(1))-(e.e(1)-h.e(1))}}}})(jQuery,this,this.document);(function(c,b,a,d){if(typeof(c.matrix)=="undefined"){c.extend({matrix:{}})}c.extend(c.matrix,{identity:function(g){g=g||2;var h=g*g,j=new Array(h),f=g+1;for(var e=0;e<h;e++){j[e]=(e%f)===0?1:0}return new c.matrix["M"+g+"x"+g](j)},matrix:function(){var e=Array.prototype.slice.call(arguments);switch(arguments.length){case 4:return new c.matrix.M2x2(e[0],e[2],e[1],e[3]);case 6:return new c.matrix.M3x3(e[0],e[2],e[4],e[1],e[3],e[5],0,0,1)}},reflect:function(){return new c.matrix.M2x2(-1,0,0,-1)},reflectX:function(){return new c.matrix.M2x2(1,0,0,-1)},reflectXY:function(){return new c.matrix.M2x2(0,1,1,0)},reflectY:function(){return new c.matrix.M2x2(-1,0,0,1)},rotate:function(i){var f=c.angle.degreeToRadian(i),h=Math.cos(f),j=Math.sin(f);var g=h,e=j,l=-j,k=h;return new c.matrix.M2x2(g,l,e,k)},scale:function(f,e){f=f||f===0?f:1;e=e||e===0?e:f;return new c.matrix.M2x2(f,0,0,e)},scaleX:function(e){return c.matrix.scale(e,1)},scaleY:function(e){return c.matrix.scale(1,e)},skew:function(h,f){h=h||0;f=f||0;var i=c.angle.degreeToRadian(h),g=c.angle.degreeToRadian(f),e=Math.tan(i),j=Math.tan(g);return new c.matrix.M2x2(1,e,j,1)},skewX:function(e){return c.matrix.skew(e)},skewY:function(e){return c.matrix.skew(0,e)},translate:function(f,e){f=f||0;e=e||0;return new c.matrix.M3x3(1,0,f,0,1,e,0,0,1)}})})(jQuery,this,this.document);
+(function(g,h,k,c){var i=/progid:DXImageTransform\.Microsoft\.Matrix\(.*?\)/;var d=k.createElement("modernizr"),e=d.style;function o(m){return parseFloat(m)}function n(){var m={transformProperty:"",MozTransform:"-moz-",WebkitTransform:"-webkit-",OTransform:"-o-",msTransform:"-ms-"};for(var q in m){if(typeof e[q]!="undefined"){return m[q]}}return null}function p(){if(typeof(h.Modernizr)!=="undefined"){return Modernizr.csstransforms}var q=["transformProperty","WebkitTransform","MozTransform","OTransform","msTransform"];for(var m in q){if(e[q[m]]!==c){return true}}}var a=n(),j=a!==null?a+"transform":false,l=a!==null?a+"transform-origin":false;g.support.csstransforms=p();g.extend({transform:function(m){m.transform=this;this.$elem=g(m);this.applyingMatrix=false;this.matrix=null;this.height=null;this.width=null;this.outerHeight=null;this.outerWidth=null;this.boxSizingValue=null;this.boxSizingProperty=null;this.attr=null;this.transformProperty=j;this.transformOriginProperty=l}});g.extend(g.transform,{funcs:["matrix","origin","reflect","reflectX","reflectXY","reflectY","rotate","scale","scaleX","scaleY","skew","skewX","skewY","translate","translateX","translateY"],rfunc:{angle:/^rotate|skew[X|Y]?$/,length:/^origin|translate[X|Y]?$/,scale:/^scale[X|Y]?$/,reflect:/^reflect(XY|X|Y)?$/}});g.fn.transform=function(m,q){return this.each(function(){var r=this.transform||new g.transform(this);if(m){r.exec(m,q)}})};g.transform.prototype={exec:function(m,q){q=g.extend(true,{forceMatrix:false,preserve:false},q);this.attr=null;if(q.preserve){m=g.extend(true,this.getAttrs(true,true),m)}else{m=g.extend(true,{},m)}this.setAttrs(m);if(g.support.csstransforms&&!q.forceMatrix){return this.execFuncs(m)}else{if(g.browser.msie||(g.support.csstransforms&&q.forceMatrix)){return this.execMatrix(m)}}return false},execFuncs:function(q){var m=[];for(var r in q){if(r=="origin"){this[r].apply(this,g.isArray(q[r])?q[r]:[q[r]])}else{if(g.inArray(r,g.transform.funcs)!=-1){m.push(this.createTransformFunc(r,q[r]))}}}this.$elem.css(j,m.join(" "));return true},execMatrix:function(r){var C,x,z;for(var t in r){if(g.matrix[t]){z=g.isArray(r[t])?r[t]:[r[t]];z=g.map(z,o);x=g.matrix[t].apply(this,z);C=C?C.x(x):x}else{if(t=="origin"){z=g.isArray(r[t])?r[t]:[r[t]];this[t].apply(this,z)}}}C=C||g.matrix.identity();var D=parseFloat(C.e(1,1).toFixed(6)),B=parseFloat(C.e(2,1).toFixed(6)),A=parseFloat(C.e(1,2).toFixed(6)),y=parseFloat(C.e(2,2).toFixed(6)),v=C.rows===3?parseFloat(C.e(1,3).toFixed(6)):0,u=C.rows===3?parseFloat(C.e(2,3).toFixed(6)):0;if(g.support.csstransforms&&a==="-moz-"){this.$elem.css(j,"matrix("+D+", "+B+", "+A+", "+y+", "+v+"px, "+u+"px)")}else{if(g.support.csstransforms){this.$elem.css(j,"matrix("+D+", "+B+", "+A+", "+y+", "+v+", "+u+")")}else{if(g.browser.msie){var m=", FilterType='nearest neighbor'";var q=this.$elem[0].style;var w="progid:DXImageTransform.Microsoft.Matrix(M11="+D+", M12="+A+", M21="+B+", M22="+y+", sizingMethod='auto expand'"+m+")";var s=q.filter||jQuery.curCSS(this.$elem[0],"filter")||"";q.filter=i.test(s)?s.replace(i,w):s?s+" "+w:w;this.applyingMatrix=true;this.matrix=C;this.fixPosition(C,v,u);this.applyingMatrix=false;this.matrix=null}}}return true},origin:function(m,q){if(g.support.csstransforms){if(typeof q==="undefined"){this.$elem.css(l,m)}else{this.$elem.css(l,m+" "+q)}return true}switch(m){case"left":m="0";break;case"right":m="100%";break;case"center":case c:m="50%"}switch(q){case"top":q="0";break;case"bottom":q="100%";break;case"center":case c:q="50%"}if(/%/.test(m)&&/%/.test(q)){this.setAttr("origin",[m,q]);return true}this.setAttr("origin",[/%/.test(m)?m:parseFloat(m)+"px",/%/.test(q)?q:parseFloat(q)+"px"]);return true},createTransformFunc:function(s,t){if(g.transform.rfunc.reflect.test(s)){var r=t?g.matrix[s]():g.matrix.identity(),q=r.e(1,1),m=r.e(2,1),v=r.e(1,2),u=r.e(2,2);return"matrix("+q+", "+m+", "+v+", "+u+", 0, 0)"}t=f(s,t);if(!g.isArray(t)){return s+"("+t+")"}else{if(s=="matrix"){if(a==="-moz-"&&t[4]){t[4]=t[4]+"px"}if(a==="-moz-"&&t[5]){t[5]=t[5]+"px"}return"matrix("+t[0]+", "+t[1]+", "+t[2]+", "+t[3]+", "+(t[4]||0)+", "+(t[5]||0)+")"}else{return s+"("+t[0]+", "+t[1]+")"}}},fixPosition:function(y,v,u,A,m){var t=new g.matrix.calc(y,this.safeOuterHeight(),this.safeOuterWidth()),z=this.getAttr("origin");var s=t.originOffset(new g.matrix.V2(/%/.test(z[0])?parseFloat(z[0])/100*t.outerWidth:parseFloat(z[0]),/%/.test(z[1])?parseFloat(z[1])/100*t.outerHeight:parseFloat(z[1])));var q=t.sides();var r=this.$elem.css("position");if(r=="static"){r="relative"}var x={top:0,left:0};var w={position:r,top:(s.top+u+q.top+x.top)+"px",left:(s.left+v+q.left+x.left)+"px",zoom:1};this.$elem.css(w)}};var b=/^([\+\-]=)?([\d+.\-]+)(.*)$/;function f(q,v){var x=!g.isArray(v)?[v]:v,m=g.transform.rfunc.angle,w=g.transform.rfunc.length;for(var s=0,t=x.length;s<t;s++){var r=b.exec(x[s]),u="";if(m.test(q)){u="deg";if(r[3]&&!g.angle.runit.test(r[3])){r[3]=null}}else{if(w.test(q)){u="px"}}if(!r){x[s]=0+u}else{if(!r[3]){x[s]+=u}}}return t==1?x[0]:x}})(jQuery,this,this.document);(function(d,c,a,f){d.extend(d.transform.prototype,{safeOuterHeight:function(){return this.safeOuterLength("height")},safeOuterWidth:function(){return this.safeOuterLength("width")},safeOuterLength:function(l){var o="outer"+(l=="width"?"Width":"Height");if(d.browser.msie){l=l=="width"?"width":"height";if(this.applyingMatrix&&!this[o]&&this.matrix){var k=new d.matrix.calc(this.matrix,1,1),m=k.offset(),g=this.$elem[o]()/m[l];this[o]=g;return g}else{if(this.applyingMatrix&&this[o]){return this[o]}}var n={height:["top","bottom"],width:["left","right"]};var h=this.$elem[0],j=parseFloat(d.curCSS(h,l,true)),p=this.boxSizingProperty,i=this.boxSizingValue;if(!this.boxSizingProperty){p=this.boxSizingProperty=e()||"box-sizing";i=this.boxSizingValue=this.$elem.css(p)||"content-box"}if(this[o]&&this[l]==j){return this[o]}else{this[l]=j}if(p&&(i=="padding-box"||i=="content-box")){j+=parseFloat(d.curCSS(h,"padding-"+n[l][0],true))||0+parseFloat(d.curCSS(h,"padding-"+n[l][1],true))||0}if(p&&i=="content-box"){j+=parseFloat(d.curCSS(h,"border-"+n[l][0]+"-width",true))||0+parseFloat(d.curCSS(h,"border-"+n[l][1]+"-width",true))||0}this[o]=j;return j}return this.$elem[o]()}});var b=null;function e(){if(b){return b}var h={boxSizing:"box-sizing",MozBoxSizing:"-moz-box-sizing",WebkitBoxSizing:"-webkit-box-sizing",OBoxSizing:"-o-box-sizing"},g=a.body;for(var i in h){if(typeof g.style[i]!="undefined"){b=h[i];return b}}return null}})(jQuery,this,this.document);(function(g,f,b,h){var d=/([\w\-]*?)\((.*?)\)/g,a="data-transform",e=/\s/,c=/,\s?/;g.extend(g.transform.prototype,{setAttrs:function(i){var j="",l;for(var k in i){l=i[k];if(g.isArray(l)){l=l.join(", ")}j+=" "+k+"("+l+")"}this.attr=g.trim(j);this.$elem.attr(a,this.attr)},setAttr:function(k,l){if(g.isArray(l)){l=l.join(", ")}var j=this.attr||this.$elem.attr(a);if(!j||j.indexOf(k)>-1){this.attr=g.trim(j+" "+k+"("+l+")");this.$elem.attr(a,this.attr)}else{var i=[],m;d.lastIndex=0;while((result=d.exec(j))!==null){if(k==m[1]){i.push(k+"("+l+")")}else{i.push(m[0])}}this.attr=i.join(" ");this.$elem.attr(a,this.attr)}},getAttrs:function(){var j=this.attr||this.$elem.attr(a);if(!j){return{}}var i={},l,k;d.lastIndex=0;while((l=d.exec(j))!==null){if(l){k=l[2].split(c);i[l[1]]=k.length==1?k[0]:k}}return i},getAttr:function(j){var i=this.getAttrs();if(typeof i[j]!=="undefined"){return i[j]}if(j==="origin"&&g.support.csstransforms){return this.$elem.css(this.transformOriginProperty).split(e)}else{if(j==="origin"){return["50%","50%"]}}return g.cssDefault[j]||0}});if(typeof(g.cssDefault)=="undefined"){g.cssDefault={}}g.cssDefault.scale=[1,1];g.cssDefault.scaleX=1;g.cssDefault.scaleY=1;g.cssDefault.matrix=[1,0,0,1,0,0];g.cssDefault.origin=["50%","50%"];g.cssDefault.reflect=[1,0,0,1,0,0];g.cssDefault.reflectX=[1,0,0,1,0,0];g.cssDefault.reflectXY=[1,0,0,1,0,0];g.cssDefault.reflectY=[1,0,0,1,0,0];if(typeof(g.cssMultipleValues)=="undefined"){g.cssMultipleValues={}}g.extend(g.cssMultipleValues,{matrix:6,reflect:6,reflectX:6,reflectXY:6,reflectY:6,scale:{length:2,duplicate:true},skew:2,translate:2});g.each(g.transform.funcs,function(j,k){g.cssNumber[k]=true;g.cssHooks[k]={set:function(m,n){var l=m.transform||new g.transform(m),i={};i[k]=n;l.exec(i,{preserve:true})},get:function(m,l){var i=m.transform||new g.transform(m);return i.getAttr(k)}}});g.each(["reflect","reflectX","reflectXY","reflectY"],function(j,k){g.cssHooks[k].get=function(m,l){var i=m.transform||new g.transform(m);return i.getAttr("matrix")||g.cssDefault[k]}})})(jQuery,this,this.document);(function(e,d,c,f){var b=/^([+\-]=)?([\d+.\-]+)(.*)$/;var g=e.fn.animate;e.fn.animate=function(l,i,k,j){var h=jQuery.speed(i,k,j);if(!jQuery.isEmptyObject(l)){jQuery.each(l,function(m,n){if(e.cssMultipleValues[m]){if(typeof h.multiple==="undefined"){h.multiple={}}h.multiple[m]=n.toString();l[m]=parseFloat(n)}})}return g.apply(this,[arguments[0],h])};var a=e.fx.prototype.custom;e.fx.prototype.custom=function(){var s=e.cssMultipleValues[this.prop];if(s){this.values=[];var r=this.options.multiple[this.prop],p=e(this.elem).css(this.prop),h=e.cssDefault[this.prop]||0;if(!e.isArray(p)){p=[p]}if(!e.isArray(r)){if(e.type(r)==="string"){r=r.split(",")}else{r=[r]}}var k=s.length||s,o=0;while(r.length<k){r.push(s.duplicate?r[0]:h[o]||0);o++}var j,n,m,q,l=this;e.each(r,function(t,u){if(p[t]){j=p[t]}else{if(h[t]&&!s.duplicate){j=h[t]}else{if(s.duplicate){j=p[0]}else{j=0}}}j=parseFloat(j);n=b.exec(u);if(n){m=parseFloat(n[2]);q=n[3]||"px";if(n[1]){m=((n[1]==="-="?-1:1)*m)+j}}else{m=u;q=""}l.values.push({start:j,end:m,unit:q})})}return a.apply(this,arguments)};e.fx.multipleValueStep={_default:function(h){e.each(h.values,function(j,k){h.values[j].now=k.start+((k.end-k.start)*h.pos)})}};e.each(e.transform.funcs,function(h,j){e.fx.step[j]=function(l){var k=l.elem.transform||new e.transform(l.elem),i={};if(e.cssMultipleValues[j]){(e.fx.multipleValueStep[l.prop]||e.fx.multipleValueStep._default)(l);i[l.prop]=[];e.each(l.values,function(m,n){i[l.prop].push(n.now)})}else{i[l.prop]=l.now}k.exec(i,{preserve:true})}});e.each(["reflect","reflectX","reflectXY","reflectY"],function(j,k){var h=e.fx.step[k];e.fx.step[k]=function(n){var m=n.elem.transform||new e.transform(n.elem),l={};if(!n.initialized){n.start=n.initialized=true;var i=e.matrix[k]().elements;e.each(n.values,function(o){var p;switch(o){case 0:p=i[0];break;case 1:p=i[2];break;case 2:p=i[1];break;case 3:p=i[3];break;default:p=0}n.values[o].end=p;n.initialized=true})}(e.fx.multipleValueStep[n.prop]||e.fx.multipleValueStep._default)(n);l.matrix=[];e.each(n.values,function(o,p){l.matrix.push(p.now)});m.exec(l,{preserve:true})}})})(jQuery,this,this.document);(function(f,g,i,b){var c=180/Math.PI;var j=200/Math.PI;var e=Math.PI/180;var d=2/1.8;var h=0.9;var a=Math.PI/200;f.extend({angle:{runit:/(deg|g?rad)/,radianToDegree:function(k){return k*c},radianToGrad:function(k){return k*j},degreeToRadian:function(k){return k*e},degreeToGrad:function(k){return k*d},gradToDegree:function(k){return k*h},gradToRadian:function(k){return k*a}}})})(jQuery,this,this.document);(function(e,d,b,f){if(typeof(e.matrix)=="undefined"){e.extend({matrix:{}})}e.extend(e.matrix,{V2:function(g,h){if(e.isArray(arguments[0])){this.elements=arguments[0].slice(0,2)}else{this.elements=[g,h]}this.length=2},V3:function(g,i,h){if(e.isArray(arguments[0])){this.elements=arguments[0].slice(0,3)}else{this.elements=[g,i,h]}this.length=3},M2x2:function(h,g,j,i){if(e.isArray(arguments[0])){this.elements=arguments[0].slice(0,4)}else{this.elements=Array.prototype.slice.call(arguments).slice(0,4)}this.rows=2;this.cols=2},M3x3:function(l,k,j,i,h,g,o,n,m){if(e.isArray(arguments[0])){this.elements=arguments[0].slice(0,9)}else{this.elements=Array.prototype.slice.call(arguments).slice(0,9)}this.rows=3;this.cols=3}});var c={e:function(j,g){var h=this.rows,i=this.cols;if(j>h||g>h||j<1||g<1){return 0}return this.elements[(j-1)*i+g-1]}};e.extend(e.matrix.M2x2.prototype,c,{toM3x3:function(){var g=this.elements;return new e.matrix.M3x3(g[0],g[1],0,g[2],g[3],0,0,0,1)},x:function(i){var j=typeof(i.rows)==="undefined";if(!j&&i.rows==3){return this.toM3x3().x(i)}var h=this.elements,g=i.elements;if(j&&g.length==2){return new e.matrix.V2(h[0]*g[0]+h[1]*g[1],h[2]*g[0]+h[3]*g[1])}else{if(g.length==h.length){return new e.matrix.M2x2(h[0]*g[0]+h[1]*g[2],h[0]*g[1]+h[1]*g[3],h[2]*g[0]+h[3]*g[2],h[2]*g[1]+h[3]*g[3])}}return false},inverse:function(){var h=1/this.determinant(),g=this.elements;return new e.matrix.M2x2(h*g[3],h*-g[1],h*-g[2],h*g[0])},determinant:function(){var g=this.elements;return g[0]*g[3]-g[1]*g[2]}});e.extend(e.matrix.M3x3.prototype,c,{x:function(i){var j=typeof(i.rows)==="undefined";if(!j&&i.rows<3){i=i.toM3x3()}var h=this.elements,g=i.elements;if(j&&g.length==3){return new e.matrix.V3(h[0]*g[0]+h[1]*g[1]+h[2]*g[2],h[3]*g[0]+h[4]*g[1]+h[5]*g[2],h[6]*g[0]+h[7]*g[1]+h[8]*g[2])}else{if(g.length==h.length){return new e.matrix.M3x3(h[0]*g[0]+h[1]*g[3]+h[2]*g[6],h[0]*g[1]+h[1]*g[4]+h[2]*g[7],h[0]*g[2]+h[1]*g[5]+h[2]*g[8],h[3]*g[0]+h[4]*g[3]+h[5]*g[6],h[3]*g[1]+h[4]*g[4]+h[5]*g[7],h[3]*g[2]+h[4]*g[5]+h[5]*g[8],h[6]*g[0]+h[7]*g[3]+h[8]*g[6],h[6]*g[1]+h[7]*g[4]+h[8]*g[7],h[6]*g[2]+h[7]*g[5]+h[8]*g[8])}}return false},inverse:function(){var h=1/this.determinant(),g=this.elements;return new e.matrix.M3x3(h*(g[8]*g[4]-g[7]*g[5]),h*(-(g[8]*g[1]-g[7]*g[2])),h*(g[5]*g[1]-g[4]*g[2]),h*(-(g[8]*g[3]-g[6]*g[5])),h*(g[8]*g[0]-g[6]*g[2]),h*(-(g[5]*g[0]-g[3]*g[2])),h*(g[7]*g[3]-g[6]*g[4]),h*(-(g[7]*g[0]-g[6]*g[1])),h*(g[4]*g[0]-g[3]*g[1]))},determinant:function(){var g=this.elements;return g[0]*(g[8]*g[4]-g[7]*g[5])-g[3]*(g[8]*g[1]-g[7]*g[2])+g[6]*(g[5]*g[1]-g[4]*g[2])}});var a={e:function(g){return this.elements[g-1]}};e.extend(e.matrix.V2.prototype,a);e.extend(e.matrix.V3.prototype,a)})(jQuery,this,this.document);(function(c,b,a,d){if(typeof(c.matrix)=="undefined"){c.extend({matrix:{}})}c.extend(c.matrix,{calc:function(e,f,g){this.matrix=e;this.outerHeight=f;this.outerWidth=g}});c.matrix.calc.prototype={coord:function(e,i,h){h=typeof(h)!=="undefined"?h:0;var g=this.matrix,f;switch(g.rows){case 2:f=g.x(new c.matrix.V2(e,i));break;case 3:f=g.x(new c.matrix.V3(e,i,h));break}return f},corners:function(e,h){var f=!(typeof(e)!=="undefined"||typeof(h)!=="undefined"),g;if(!this.c||!f){h=h||this.outerHeight;e=e||this.outerWidth;g={tl:this.coord(0,0),bl:this.coord(0,h),tr:this.coord(e,0),br:this.coord(e,h)}}else{g=this.c}if(f){this.c=g}return g},sides:function(e){var f=e||this.corners();return{top:Math.min(f.tl.e(2),f.tr.e(2),f.br.e(2),f.bl.e(2)),bottom:Math.max(f.tl.e(2),f.tr.e(2),f.br.e(2),f.bl.e(2)),left:Math.min(f.tl.e(1),f.tr.e(1),f.br.e(1),f.bl.e(1)),right:Math.max(f.tl.e(1),f.tr.e(1),f.br.e(1),f.bl.e(1))}},offset:function(e){var f=this.sides(e);return{height:Math.abs(f.bottom-f.top),width:Math.abs(f.right-f.left)}},area:function(e){var h=e||this.corners();var g={x:h.tr.e(1)-h.tl.e(1)+h.br.e(1)-h.bl.e(1),y:h.tr.e(2)-h.tl.e(2)+h.br.e(2)-h.bl.e(2)},f={x:h.bl.e(1)-h.tl.e(1)+h.br.e(1)-h.tr.e(1),y:h.bl.e(2)-h.tl.e(2)+h.br.e(2)-h.tr.e(2)};return 0.25*Math.abs(g.e(1)*f.e(2)-g.e(2)*f.e(1))},nonAffinity:function(){var f=this.sides(),g=f.top-f.bottom,e=f.left-f.right;return parseFloat(parseFloat(Math.abs((Math.pow(g,2)+Math.pow(e,2))/(f.top*f.bottom+f.left*f.right))).toFixed(8))},originOffset:function(h,g){h=h?h:new c.matrix.V2(this.outerWidth*0.5,this.outerHeight*0.5);g=g?g:new c.matrix.V2(0,0);var e=this.coord(h.e(1),h.e(2));var f=this.coord(g.e(1),g.e(2));return{top:(f.e(2)-g.e(2))-(e.e(2)-h.e(2)),left:(f.e(1)-g.e(1))-(e.e(1)-h.e(1))}}}})(jQuery,this,this.document);(function(c,b,a,d){if(typeof(c.matrix)=="undefined"){c.extend({matrix:{}})}c.extend(c.matrix,{identity:function(g){g=g||2;var h=g*g,j=new Array(h),f=g+1;for(var e=0;e<h;e++){j[e]=(e%f)===0?1:0}return new c.matrix["M"+g+"x"+g](j)},matrix:function(){var e=Array.prototype.slice.call(arguments);switch(arguments.length){case 4:return new c.matrix.M2x2(e[0],e[2],e[1],e[3]);case 6:return new c.matrix.M3x3(e[0],e[2],e[4],e[1],e[3],e[5],0,0,1)}},reflect:function(){return new c.matrix.M2x2(-1,0,0,-1)},reflectX:function(){return new c.matrix.M2x2(1,0,0,-1)},reflectXY:function(){return new c.matrix.M2x2(0,1,1,0)},reflectY:function(){return new c.matrix.M2x2(-1,0,0,1)},rotate:function(i){var f=c.angle.degreeToRadian(i),h=Math.cos(f),j=Math.sin(f);var g=h,e=j,l=-j,k=h;return new c.matrix.M2x2(g,l,e,k)},scale:function(f,e){f=f||f===0?f:1;e=e||e===0?e:f;return new c.matrix.M2x2(f,0,0,e)},scaleX:function(e){return c.matrix.scale(e,1)},scaleY:function(e){return c.matrix.scale(1,e)},skew:function(h,f){h=h||0;f=f||0;var i=c.angle.degreeToRadian(h),g=c.angle.degreeToRadian(f),e=Math.tan(i),j=Math.tan(g);return new c.matrix.M2x2(1,e,j,1)},skewX:function(e){return c.matrix.skew(e)},skewY:function(e){return c.matrix.skew(0,e)},translate:function(f,e){f=f||0;e=e||0;return new c.matrix.M3x3(1,0,f,0,1,e,0,0,1)},translateX:function(e){return c.matrix.translate(e)},translateY:function(e){return c.matrix.translate(0,e)}})})(jQuery,this,this.document);
View
467 dist/jquery.transform.js
@@ -6,7 +6,7 @@
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
- * Date: Wed Oct 6 23:16:32 2010 -0700
+ * Date: Sun Oct 24 22:50:33 2010 -0700
*/
///////////////////////////////////////////////////////
// Transform
@@ -576,7 +576,7 @@
var rfuncvalue = /([\w\-]*?)\((.*?)\)/g, // with values
attr = 'data-transform',
rspace = /\s/,
- rcspace = /,\s/;
+ rcspace = /,\s?/;
$.extend($.transform.prototype, {
/**
@@ -609,13 +609,12 @@
if ($.isArray(value)) {
value = value.join(', ');
}
- value = $.trim(value+'');
// pull from a local variable to look it up
var transform = this.attr || this.$elem.attr(attr);
if (!transform || transform.indexOf(func) > -1) {
- // We don't have any existing values, save it
+ // we don't have any existing values, save it
// we don't have this function yet, save it
this.attr = $.trim(transform + ' ' + func + '(' + value + ')');
this.$elem.attr(attr, this.attr);
@@ -666,46 +665,93 @@
*/
getAttr: function(func) {
var attrs = this.getAttrs();
-
if (typeof attrs[func] !== 'undefined') {
return attrs[func];
}
- // animate needs sensible defaults for some props
- switch (func) {
- case 'scale': return [1, 1];
- case 'scaleX': // no break;
- case 'scaleY': return 1;
- case 'matrix': return [1, 0, 0, 1, 0, 0];
- case 'origin':
- if ($.support.csstransforms) {
- // supported browsers return percentages always
- return this.$elem.css(this.transformOriginProperty).split(rspace);
- } else {
- // just force IE to also return a percentage
- return ['50%', '50%'];
- }
+ //TODO: move the origin to a function
+ if (func === 'origin' && $.support.csstransforms) {
+ // supported browsers return percentages always
+ return this.$elem.css(this.transformOriginProperty).split(rspace);
+ } else if (func === 'origin') {
+ // just force IE to also return a percentage
+ return ['50%', '50%'];
}
- return null;
+
+ return $.cssDefault[func] || 0;
}
});
+
+ // Define default values
+ if (typeof($.cssDefault) == 'undefined') {
+ $.cssDefault = {};
+ }
+ $.cssDefault.scale = [1, 1];
+ $.cssDefault.scaleX = 1;
+ $.cssDefault.scaleY = 1;
+ $.cssDefault.matrix = [1, 0, 0, 1, 0, 0];
+ $.cssDefault.origin = ['50%', '50%']; // TODO: allow this to be a function, like get
+
+ $.cssDefault.reflect = [1, 0, 0, 1, 0, 0];
+ $.cssDefault.reflectX = [1, 0, 0, 1, 0, 0];
+ $.cssDefault.reflectXY = [1, 0, 0, 1, 0, 0];
+ $.cssDefault.reflectY = [1, 0, 0, 1, 0, 0];
+
+ // Define functons with multiple values
+ if (typeof($.cssMultipleValues) == 'undefined') {
+ $.cssMultipleValues = {};
+ }
+ $.extend($.cssMultipleValues, {
+ matrix: 6,
+
+ reflect: 6,
+ reflectX: 6,
+ reflectXY: 6,
+ reflectY: 6,
+
+ scale: {
+ length: 2,
+ duplicate: true
+ },
+ skew: 2,
+ translate: 2
+ });
+
+ // override all of the css functions
+ $.each($.transform.funcs, function(i, func) {
+ $.cssNumber[func] = true;
+ $.cssHooks[func] = {
+ set: function(elem, value) {
+ var transform = elem.transform || new $.transform(elem),
+ funcs = {};
+ funcs[func] = value;
+ transform.exec(funcs, {preserve: true});
+ },
+ get: function(elem, computed) {
+ var transform = elem.transform || new $.transform(elem);
+ return transform.getAttr(func);
+ }
+ };
+ });
+
+ // Support Reflection animation better by returning a matrix
+ $.each(['reflect', 'reflectX', 'reflectXY', 'reflectY'], function(i, func) {
+ $.cssHooks[func].get = function(elem, computed) {
+ var transform = elem.transform || new $.transform(elem);
+ return transform.getAttr('matrix') || $.cssDefault[func];
+ };
+ });
})(jQuery, this, this.document);
///////////////////////////////////////////////////////
// Animation
///////////////////////////////////////////////////////
(function($, window, document, undefined) {
- // Extend the jQuery animation to handle transform functions
/**
* @var Regex looks for units on a string
*/
var rfxnum = /^([+\-]=)?([\d+.\-]+)(.*)$/;
/**
- * @var Regex identify if additional values are hidden in the unit
- */
- var rfxmultinum = /^(.*?)\s+([+\-]=)?([\d+.\-]+)(.*)$/;
-
- /**
* Doctors prop values in the event that they contain spaces
* @param Object prop
* @param String speed
@@ -715,197 +761,112 @@
*/
var _animate = $.fn.animate;
$.fn.animate = function( prop, speed, easing, callback ) {
- //NOTE: The $.fn.animate() function is a big jerk and requires
- // you to attempt to convert the values passed into pixels.
- // So we have to doctor the values passed in here to make
- // sure $.fn.animate() won't think there's units an ruin
- // our fun.
- if (prop && !jQuery.isEmptyObject(prop)) {
- var $elem = this;
+ var optall = jQuery.speed(speed, easing, callback);
+
+ // Capture multiple values
+ if (!jQuery.isEmptyObject(prop)) {
jQuery.each( prop, function( name, val ) {
- // Clean up the numbers for space-sperated prop values
- if ($.inArray(name, $.transform.funcs) != -1) {
- // allow for reflection animation
- if ($.transform.rfunc.reflect.test(name)) {
- var m = val ? $.matrix[name]() : $.matrix.identity(),
- e = m.elements;
- val = [e[0], e[1], e[2], e[3]];
+ if ($.cssMultipleValues[name]) {
+ if (typeof optall.multiple === 'undefined') {
+ optall.multiple = {};
}
-
- var parts = rfxnum.exec(val);
- if ((parts && parts[3]) || $.isArray(val)) {
- // Either a unit was found or an array was passed
- var end, unit, values = [];
-
- if ($.isArray(val)) {
- // An array was passed
- $.each(val, function(i) {
- parts = rfxnum.exec(this);
- end = parseFloat(parts[2]);
- unit = parts[3] || "px";
-
- // Remember value
- values.push({
- end: (parts[1] ? parts[1] : '') + end,
- unit: unit
- });
- });
- } else {
- // A unit was found
- end = parseFloat( parts[2] );
- unit = parts[3] || "px";
-
- // Remember the first value
- values.push({
- end: (parts[1] ? parts[1] : '') + end,
- unit: unit
- });
-
- // Detect additional values hidden in the unit
- var i = 0;
- while (parts = rfxmultinum.exec(unit)) {
- // Fix the previous unit
- values[i].unit = parts[1];
-
- // Remember this value
- values.push({
- end: (parts[2] ? parts[2] : '') + parseFloat(parts[3]),
- unit: parts[4]
- });
- unit = parts[4];
- i++;
- }
- }
+ // force the original values onto the optall
+ optall.multiple[name] = val.toString();
- // Save the values and truncate the value to make it safe to animate
- $elem.data('data-animate-' + name, values);
- prop[name] = values[0].end; // NOTE: this propegates into the arguments object
- }
+ // reduce to a unitless number
+ prop[name] = parseFloat(val);
}
- });
+ } );
}
- //NOTE: we edit prop above
- return _animate.apply(this, arguments);
+
+ //NOTE: we edited prop above to trick animate
+ return _animate.apply(this, [arguments[0], optall]);
};
- /**
- * Returns appropriate start value for transform props
- * @param Boolean force
- * @return Number
- */
- var _cur = $.fx.prototype.cur;
- $.fx.prototype.cur = function(force) {
- //NOTE: The cur function tries to look things up on the element
- // itself as a native property first instead of as a style
- // property. However, the animate function is a big jerk
- // and it's extremely easy to poison the element.style
- // with a random property and ruin all of the fun. So, it's
- // easier to just look it up ourselves.
- if ($.inArray(this.prop, $.transform.funcs) != -1) {
- this.transform = this.transform || this.elem.transform || new $.transform(this.elem);
- var r = $.transform.rfunc;
-
- // return a single unitless number and animation will play nice
- var value = this.transform.getAttr(this.prop),
- parts = rfxnum.exec($.isArray(value) ? value[0] : value);
- if (value === null || parts === null) {
- value = r.scale.test(this.prop) || r.reflect.test(this.prop) ? 1 : 0;
- parts = [null, null, value];
+ var _custom = $.fx.prototype.custom;
+ $.fx.prototype.custom = function() {
+ var multiple = $.cssMultipleValues[this.prop];
+ if (multiple) {
+ this.values = [];
+
+ // Pull out the known values
+ var values = this.options.multiple[this.prop],
+ currentValues = $(this.elem).css(this.prop),
+ defaultValues = $.cssDefault[this.prop] || 0;
+
+ // make sure the current css value is an array
+ if (!$.isArray(currentValues)) {
+ currentValues = [currentValues];
}
- return parseFloat(parts[2]);
- }
- return _cur.apply(this, arguments);
- };
-
- /**
- * Detects the existence of a space separated value
- * @param Object fx
- * @return null
- */
- $.fx.multivalueInit = function(fx) {
- var $elem = $(fx.elem),
- values = fx.transform.getAttr(fx.prop), // existing values
- initValues = $elem.data('data-animate-' + fx.prop); // new values passed into animate
-
- if (initValues) {
- $elem.removeData('data-animate-' + fx.prop); // unremember the saved property
- }
-
- if ($.transform.rfunc.reflect.test(fx.prop)) {
- values = fx.transform.getAttr('matrix');
- }
-
- fx.values = [];
-
- // If we found a previous array but we're only setting one value, we need to set both
- if ($.isArray(values) && !$.isArray(initValues)) {
- initValues = [
- {
- end: parseFloat(fx.end),
- unit: fx.unit
- },
- {
- end: $.transform.rfunc.scale.test(fx.prop) ? 1 : 0,
- unit: fx.unit
- }
- ];
- }
-
- // If we altered the values before
- // This happens in the doctored animate function when we pass a unit or multiple values
- if (initValues) {
- var start,
- rscalefunc = $.transform.rfunc.scale,
- parts;
- $.each(initValues, function(i, val) {
- // pull out the start value
- if ($.isArray(values)) {
- start = values[i];
- } else if (i > 0) {
- // scale duplicates the values for x and y
- start = rscalefunc.test(fx.prop) ? values : null;
+
+ // make sure the new values are an array
+ if (!$.isArray(values)) {
+ if ($.type(values) === 'string') {
+ values = values.split(',');
} else {
- start = values;
+ values = [values];
}
-
- // if we didn't find a start value
- if (!start && start !== 0) {
- start = rscalefunc.test(fx.prop) ? 1 : 0;
+ }
+
+ // make sure we have enough new values
+ var length = multiple.length || multiple, i = 0;
+ while (values.length < length) {
+ values.push(multiple.duplicate ? values[0] : defaultValues[i] || 0);
+ i++;
+ }
+
+ // calculate a start, end and unit for each new value
+ var start, parts, end, unit, fx = this;
+
+ $.each(values, function(i, val) {
+ // find a sensible start value
+ if (currentValues[i]) {
+ start = currentValues[i];
+ } else if (defaultValues[i] && !multiple.duplicate) {
+ start = defaultValues[i];
+ } else if (multiple.duplicate) {
+ start = currentValues[0];
+ } else {
+ start = 0;
}
-
- // ensure a number
start = parseFloat(start);
- // handle the existence of += and -= prefixes
- parts = rfxnum.exec(val.end);
- if (parts && parts[1]) {
- val.end = ((parts[1] === "-=" ? -1 : 1) * parseFloat(parts[2])) + start;
+ // parse the value with a regex
+ parts = rfxnum.exec(val);
+
+ if (parts) {
+ // we found a sensible value and unit
+ end = parseFloat( parts[2] );
+ unit = parts[3] || "px"; //TODO: change to an appropriate default unit
+
+ // If a +=/-= token was provided, we're doing a relative animation
+ if (parts[1]) {
+ end = ((parts[1] === "-=" ? -1 : 1) * end) + start;
+ }
+ } else {
+ // I don't know when this would happen
+ end = val;
+ unit = '';
}
// Save the values
fx.values.push({
- start: parseFloat(start),
- end: parseFloat(val.end),
- unit: val.unit
- });
- });
- } else {
- // Save the known value
- fx.values.push({
- start: parseFloat(fx.start),
- end: parseFloat(fx.end), // force a Number
- unit: fx.unit
+ start: start,
+ end: end,
+ unit: unit
+ });
});
}
+ return _custom.apply(this, arguments);
};
-
+
/**
* Animates a multi value attribute
* @param Object fx
* @return null
*/
- $.fx.multivalueStep = {
+ $.fx.multipleValueStep = {
_default: function(fx) {
$.each(fx.values, function(i, val) {
fx.values[i].now = val.start + ((val.end - val.start) * fx.pos);
@@ -918,72 +879,56 @@
*/
$.each($.transform.funcs, function(i, func) {
$.fx.step[func] = function(fx) {
- // Initialize the transformation
- if (!fx.transformInit) {
- fx.transform = fx.transform || fx.elem.transform || new $.transform(fx.elem);
-
- // Handle multiple values
- $.fx.multivalueInit(fx);
- if (fx.values.length > 1) {
- fx.multiple = true;
- }
-
- // Force degrees for angles, Remove units for unitless
- var r = $.transform.rfunc;
- if (r.angle.test(fx.prop)) {
- //TODO: we should convert from other rational units
- fx.unit = 'deg';
- } else if (r.scale.test(fx.prop)) {
- fx.unit = '';
- } else if (r.reflect.test(fx.prop)) {
- //TODO: for animation purposes, this is a matrix and can be animated (although it looks silly)
- fx.unit = ''; //this is a boolean func
- } else if (fx.prop == 'matrix') {
- fx.unit = '';
- }
- //TODO: I guess we already foced length units earlier
-
- // Force all units on multiple values to be the same
- //TODO: we should convert from other rational units
- $.each(fx.values, function(i) {fx.values[i].unit = fx.unit;});
-
- fx.transformInit = true;
- }
-
-
- // Increment all of the values
- if (fx.multiple) {
- ($.fx.multivalueStep[fx.prop] || $.fx.multivalueStep._default)(fx);
+ var transform = fx.elem.transform || new $.transform(fx.elem),
+ funcs = {};
+
+ if ($.cssMultipleValues[func]) {
+ ($.fx.multipleValueStep[fx.prop] || $.fx.multipleValueStep._default)(fx);
+ funcs[fx.prop] = [];
+ $.each(fx.values, function(i, val) {
+ funcs[fx.prop].push(val.now);
+ });
} else {
- fx.values[0].now = fx.now;
+ funcs[fx.prop] = fx.now;
}
- var values = [];
-
- // Do some value correction and join the values
- $.each(fx.values, function(i, value) {
- // Keep angles below 360 in either direction.
- if (value.unit == 'deg') {
- while (value.now >= 360 ) {
- value.now -= 360;
- }
- while (value.now <= -360 ) {
- value.now += 360;
- }
- }
- // TODO: handle reflection matrices here
+ transform.exec(funcs, {preserve: true});
+ };
+ });
+
+ // Support Reflection animation
+ $.each(['reflect', 'reflectX', 'reflectXY', 'reflectY'], function(i, func) {
+ var _step = $.fx.step[func];
+ $.fx.step[func] = function(fx) {
+ var transform = fx.elem.transform || new $.transform(fx.elem),
+ funcs = {};
+
+ if (!fx.initialized) {
+ fx.start =
+ fx.initialized = true;
+ var values = $.matrix[func]().elements;
- //Pretty up the final value (use the double parseFloat
- // to correct super small decimals)
- values.push(parseFloat(parseFloat(value.now).toFixed(8)) + value.unit);
+ $.each(fx.values, function(i) {
+ var val;
+ switch (i) {
+ case 0: val = values[0]; break;
+ case 1: val = values[2]; break;
+ case 2: val = values[1]; break;
+ case 3: val = values[3]; break;
+ default: val = 0;
+ }
+ fx.values[i].end = val;
+ fx.initialized = true;
+ });
+ }
+
+ ($.fx.multipleValueStep[fx.prop] || $.fx.multipleValueStep._default)(fx);
+ funcs.matrix = [];
+ $.each(fx.values, function(i, val) {
+ funcs.matrix.push(val.now);
});
- // Apply the transformation
- var funcs = {},
- prop = $.transform.rfunc.reflect.test(fx.prop) ? 'matrix' : fx.prop;
-
- funcs[prop] = fx.multiple ? values : values[0];
- fx.transform.exec(funcs, {preserve: true});
+ transform.exec(funcs, {preserve: true});
};
});
})(jQuery, this, this.document);
@@ -1767,6 +1712,26 @@
0, 1, ty,
0, 0, 1
);
+ },
+
+ /**
+ * Translate on the X-axis
+ * @param Number tx
+ * @return Matrix
+ * @link http://www.w3.org/TR/SVG/coords.html#TranslationDefined
+ */
+ translateX: function (tx) {
+ return $.matrix.translate(tx);
+ },
+
+ /**
+ * Translate on the Y-axis
+ * @param Number ty
+ * @return Matrix
+ * @link http://www.w3.org/TR/SVG/coords.html#TranslationDefined
+ */
+ translateY: function (ty) {
+ return $.matrix.translate(0, ty);
}
});
})(jQuery, this, this.document);
View
16 src/jquery.transform.animate.js
@@ -116,7 +116,7 @@
});
}
return _custom.apply(this, arguments);
- }
+ };
/**
* Animates a multi value attribute
@@ -179,15 +179,11 @@
});
}
- if ($.cssMultipleValues[func]) {
- ($.fx.multipleValueStep[fx.prop] || $.fx.multipleValueStep._default)(fx);
- funcs['matrix'] = [];
- $.each(fx.values, function(i, val) {
- funcs['matrix'].push(val.now);
- });
- } else {
- funcs['matrix'] = fx.now;
- }
+ ($.fx.multipleValueStep[fx.prop] || $.fx.multipleValueStep._default)(fx);
+ funcs.matrix = [];
+ $.each(fx.values, function(i, val) {
+ funcs.matrix.push(val.now);
+ });
transform.exec(funcs, {preserve: true});
};
View
5 test/_test.html
@@ -46,9 +46,8 @@
<script type="text/javascript">
var $elem = $('.transform');
- $elem.eq(0).animate({reflectXY: 1});
- $elem.eq(1).transform({reflectXY: 1});
- $elem.eq(2).css({reflectXY: 1});
+ $elem.animate({scale : 1.5}, "slow").animate({scale : 1}, "slow");
+
$('.transform').click(function() {
var $elem = $(this);
Please sign in to comment.
Something went wrong with that request. Please try again.