Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Finished testing in IE. Units should be correctly handled for all tra…

…nsformations and animations including origin and percentages.
  • Loading branch information...
commit 084297afd60bc6cc96a10c1aad58690c03f5d1a7 1 parent a7ffd6c
@heygrady authored
View
125 dist/jquery.transform-0.9.0pre.js → dist/jquery.transform-0.9.0.js
@@ -1,12 +1,12 @@
/*!
- * jQuery 2d Transform v0.9.0pre
+ * jQuery 2d Transform v0.9.0
* http://wiki.github.com/heygrady/transform/
*
* Copyright 2010, Grady Kuhnline
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
- * Date: Sun Nov 7 23:14:31 2010 -0800
+ * Date: Sun Nov 14 13:45:35 2010 -0800
*/
///////////////////////////////////////////////////////
// Transform
@@ -15,7 +15,9 @@
/**
* @var Regex identify the matrix filter in IE
*/
- var rmatrix = /progid:DXImageTransform\.Microsoft\.Matrix\(.*?\)/;
+ var rmatrix = /progid:DXImageTransform\.Microsoft\.Matrix\(.*?\)/,
+ rfxnum = /^([\+\-]=)?([\d+.\-]+)(.*)$/,
+ rperc = /%/;
// Steal some code from Modernizr
var m = document.createElement( 'modernizr' ),
@@ -119,30 +121,7 @@
/**
* @var Array list of all valid transform functions
*/
- funcs: ['matrix', 'origin', 'reflect', 'reflectX', 'reflectXY', 'reflectY', 'rotate', 'scale', 'scaleX', 'scaleY', 'skew', 'skewX', 'skewY', 'translate', 'translateX', 'translateY'],
-
- //TODO: these regexes are not long for this world
- rfunc: {
- /**
- * @var Regex identifies functions that require an angle unit
- */
- angle: /^rotate|skew[X|Y]?$/,
-
- /**
- * @var Regex identifies functions that require a length unit
- */
- length: /^origin|translate[X|Y]?$/,
-
- /**
- * @var Regex identifies functions that do not require a unit
- */
- scale: /^scale[X|Y]?$/,
-
- /**
- * @var Regex reflection functions
- */
- reflect: /^reflect(XY|X|Y)?$/
- }
+ funcs: ['matrix', 'origin', 'reflect', 'reflectX', 'reflectXY', 'reflectY', 'rotate', 'scale', 'scaleX', 'scaleY', 'skew', 'skewX', 'skewY', 'translate', 'translateX', 'translateY']
});
/**
@@ -225,18 +204,27 @@
tempMatrix,
args;
- var elem = this.$elem[0];
- function normalPixels(val) {
+ var elem = this.$elem[0],
+ _this = this;
+ function normalPixels(val, i) {
+ if (rperc.test(val)) {
+ // this really only applies to translation
+ return parseFloat(val) / 100 * _this['safeOuter' + (i ? 'Height' : 'Width')]();
+ }
return toPx(elem, val);
}
+ var rtranslate = /translate[X|Y]?/,
+ trans = [];
+
for (var func in funcs) {
+ switch ($.type(funcs[func])) {
+ case 'array': args = funcs[func]; break;
+ case 'string': args = $.map(funcs[func].split(','), $.trim); break;
+ default: args = [funcs[func]];
+ }
+
if ($.matrix[func]) {
- switch ($.type(funcs[func])) {
- case 'array': args = funcs[func]; break;
- case 'string': args = $.map(funcs[func].split(','), $.trim);break;
- default: args = [funcs[func]];
- }
if ($.cssAngle[func]) {
// normalize on degrees
@@ -249,20 +237,23 @@
args = $.map(args, stripUnits);
}
- // TODO: translation and origin should be applied last
- // TODO: should hold translations until the extreme end
tempMatrix = $.matrix[func].apply(this, args);
- matrix = matrix ? matrix.x(tempMatrix) : tempMatrix;
+ if (rtranslate.test(func)) {
+ //defer translation
+ trans.push(tempMatrix);
+ } else {
+ matrix = matrix ? matrix.x(tempMatrix) : tempMatrix;
+ }
} else if (func == 'origin') {
- //TODO: this is a dumb way to handle the origin for a matrix
- args = $.isArray(funcs[func]) ? funcs[func] : [funcs[func]];
this[func].apply(this, args);
}
}
// check that we have a matrix
- // TODO: This will result in a filter being needlessly set in IE
matrix = matrix || $.matrix.identity();
+
+ // Apply translation
+ $.each(trans, function(i, val) { matrix = matrix.x(val); });
// pull out the relevant values
var a = parseFloat(matrix.e(1,1).toFixed(6)),
@@ -336,17 +327,12 @@
case undefined: y = '50%'; //TODO: does this work?
}
- // store percentages directly
- if (/%/.test(x) && /%/.test(y)) {
- this.setAttr('origin', [x, y]);
- return true;
- }
-
// store mixed values with units, assumed pixels
this.setAttr('origin', [
- /%/.test(x) ? x : parseFloat(x) + 'px',
- /%/.test(y) ? y : parseFloat(y) + 'px'
+ rperc.test(x) ? x : toPx(this.$elem[0], x) + 'px',
+ rperc.test(y) ? y : toPx(this.$elem[0], y) + 'px'
]);
+ //console.log(this.getAttr('origin'));
return true;
},
@@ -385,11 +371,11 @@
// now we need to fix it!
var calc = new $.matrix.calc(matrix, this.safeOuterHeight(), this.safeOuterWidth()),
origin = this.getAttr('origin'); // mixed percentages and px
-
+
// translate a 0, 0 origin to the current origin
var offset = calc.originOffset(new $.matrix.V2(
- /%/.test(origin[0]) ? parseFloat(origin[0])/100*calc.outerWidth : parseFloat(origin[0]),
- /%/.test(origin[1]) ? parseFloat(origin[1])/100*calc.outerHeight : parseFloat(origin[1])
+ rperc.test(origin[0]) ? parseFloat(origin[0])/100*calc.outerWidth : parseFloat(origin[0]),
+ rperc.test(origin[1]) ? parseFloat(origin[1])/100*calc.outerHeight : parseFloat(origin[1])
));
// IE glues the top-most and left-most pixels of the transformed object to top/left of the original object
@@ -423,13 +409,13 @@
* @param string func
* @param Mixed value
*/
- var rfxnum = /^([\+\-]=)?([\d+.\-]+)(.*)$/;
function toPx(elem, val) {
- var parts = rfxnum.exec($.trim(val)),
- prop = 'paddingBottom',
- orig = $.style( elem, prop );
-
- if (parts[3]) {
+ var parts = rfxnum.exec($.trim(val));
+
+ if (parts[3] && parts[3] !== 'px') {
+ var prop = 'paddingBottom',
+ orig = $.style( elem, prop );
+
$.style( elem, prop, val );
val = cur( elem, prop );
$.style( elem, prop, orig );
@@ -479,7 +465,7 @@
safeOuterLength: function(dim) {
var funcName = 'outer' + (dim == 'width' ? 'Width' : 'Height');
- if ($.browser.msie) {
+ if (!$.support.csstransforms && $.browser.msie) {
// make the variables more generic
dim = dim == 'width' ? 'width' : 'height';
@@ -615,8 +601,7 @@
// pull from a local variable to look it up
var transform = this.attr || this.$elem.attr(attr);
-
- if (!transform || transform.indexOf(func) > -1) {
+ if (!transform || transform.indexOf(func) == -1) {
// we don't have any existing values, save it
// we don't have this function yet, save it
this.attr = $.trim(transform + ' ' + func + '(' + value + ')');
@@ -627,7 +612,7 @@
// regex split
rfuncvalue.lastIndex = 0; // reset the regex pointer
- while ((result = rfuncvalue.exec(transform)) !== null) {
+ while (parts = rfuncvalue.exec(transform)) {
if (func == parts[1]) {
funcs.push(func + '(' + value + ')');
} else {
@@ -867,6 +852,7 @@
// calculate a start, end and unit for each new value
var start, parts, end, //unit,
fx = this,
+ transform = fx.elem.transform;
orig = $.style(fx.elem, prop);
$.each(values, function(i, val) {
@@ -886,14 +872,17 @@
start = $.angle.toDegree(start);
} else if (!$.cssNumber[fx.prop]) {
parts = rfxnum.exec($.trim(start));
- if (parts[3]) {
- $.style( fx.elem, prop, start);
- start = cur(fx.elem, prop);
- $.style( fx.elem, prop, orig);
+ if (parts[3] && parts[3] !== 'px') {
+ if (parts[3] === '%') {
+ start = parseFloat( parts[2] ) / 100 * transform['safeOuter' + (i ? 'Height' : 'Width')]();
+ } else {
+ $.style( fx.elem, prop, start);
+ start = cur(fx.elem, prop);
+ $.style( fx.elem, prop, orig);
+ }
}
- } else {
- start = parseFloat(start);
}
+ start = parseFloat(start);
// parse the value with a regex
parts = rfxnum.exec($.trim(val));
@@ -906,6 +895,8 @@
if (angle) {
end = $.angle.toDegree(end + unit);
unit = 'deg';
+ } else if (!$.cssNumber[fx.prop] && unit === '%') {
+ start = (start / transform['safeOuter' + (i ? 'Height' : 'Width')]()) * 100;
} else if (!$.cssNumber[fx.prop] && unit !== 'px') {
$.style( fx.elem, prop, (end || 1) + unit);
start = ((end || 1) / cur(fx.elem, prop)) * start;
View
11 dist/jquery.transform-0.9.0.min.js
@@ -0,0 +1,11 @@
+/*
+ * jQuery 2d Transform v0.9.0
+ * http://wiki.github.com/heygrady/transform/
+ *
+ * Copyright 2010, Grady Kuhnline
+ * Dual licensed under the MIT or GPL Version 2 licenses.
+ * http://jquery.org/license
+ *
+ * Date: Sun Nov 14 13:45:35 2010 -0800
+ */
+(function(f,g,j,b){var h=/progid:DXImageTransform\.Microsoft\.Matrix\(.*?\)/,c=/^([\+\-]=)?([\d+.\-]+)(.*)$/,q=/%/;var d=j.createElement("modernizr"),e=d.style;function n(m){return parseFloat(m)}function l(){var m={transformProperty:"",MozTransform:"-moz-",WebkitTransform:"-webkit-",OTransform:"-o-",msTransform:"-ms-"};for(var s in m){if(typeof e[s]!="undefined"){return m[s]}}return null}function r(){if(typeof(g.Modernizr)!=="undefined"){return Modernizr.csstransforms}var s=["transformProperty","WebkitTransform","MozTransform","OTransform","msTransform"];for(var m in s){if(e[s[m]]!==b){return true}}}var a=l(),i=a!==null?a+"transform":false,k=a!==null?a+"transform-origin":false;f.support.csstransforms=r();if(a=="-ms-"){i="msTransform";k="msTransformOrigin"}f.extend({transform:function(m){m.transform=this;this.$elem=f(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=i;this.transformOriginProperty=k}});f.extend(f.transform,{funcs:["matrix","origin","reflect","reflectX","reflectXY","reflectY","rotate","scale","scaleX","scaleY","skew","skewX","skewY","translate","translateX","translateY"]});f.fn.transform=function(m,s){return this.each(function(){var u=this.transform||new f.transform(this);if(m){u.exec(m,s)}})};f.transform.prototype={exec:function(m,s){s=f.extend(true,{forceMatrix:false,preserve:false},s);this.attr=null;if(s.preserve){m=f.extend(true,this.getAttrs(true,true),m)}else{m=f.extend(true,{},m)}this.setAttrs(m);if(f.support.csstransforms&&!s.forceMatrix){return this.execFuncs(m)}else{if(f.browser.msie||(f.support.csstransforms&&s.forceMatrix)){return this.execMatrix(m)}}return false},execFuncs:function(s){var m=[];for(var t in s){if(t=="origin"){this[t].apply(this,f.isArray(s[t])?s[t]:[s[t]])}else{if(f.inArray(t,f.transform.funcs)!=-1){m.push(this.createTransformFunc(t,s[t]))}}}this.$elem.css(i,m.join(" "));return true},execMatrix:function(y){var B,w,s;var E=this.$elem[0],A=this;function z(M,L){if(q.test(M)){return parseFloat(M)/100*A["safeOuter"+(L?"Height":"Width")]()}return o(E,M)}var m=/translate[X|Y]?/,t=[];for(var u in y){switch(f.type(y[u])){case"array":s=y[u];break;case"string":s=f.map(y[u].split(","),f.trim);break;default:s=[y[u]]}if(f.matrix[u]){if(f.cssAngle[u]){s=f.map(s,f.angle.toDegree)}else{if(!f.cssNumber[u]){s=f.map(s,z)}else{s=f.map(s,n)}}w=f.matrix[u].apply(this,s);if(m.test(u)){t.push(w)}else{B=B?B.x(w):w}}else{if(u=="origin"){this[u].apply(this,s)}}}B=B||f.matrix.identity();f.each(t,function(L,M){B=B.x(M)});var J=parseFloat(B.e(1,1).toFixed(6)),H=parseFloat(B.e(2,1).toFixed(6)),G=parseFloat(B.e(1,2).toFixed(6)),F=parseFloat(B.e(2,2).toFixed(6)),K=B.rows===3?parseFloat(B.e(1,3).toFixed(6)):0,I=B.rows===3?parseFloat(B.e(2,3).toFixed(6)):0;if(f.support.csstransforms&&a==="-moz-"){this.$elem.css(i,"matrix("+J+", "+H+", "+G+", "+F+", "+K+"px, "+I+"px)")}else{if(f.support.csstransforms){this.$elem.css(i,"matrix("+J+", "+H+", "+G+", "+F+", "+K+", "+I+")")}else{if(f.browser.msie){var v=", FilterType='nearest neighbor'";var C=this.$elem[0].style;var D="progid:DXImageTransform.Microsoft.Matrix(M11="+J+", M12="+G+", M21="+H+", M22="+F+", sizingMethod='auto expand'"+v+")";var x=C.filter||f.curCSS(this.$elem[0],"filter")||"";C.filter=h.test(x)?x.replace(h,D):x?x+" "+D:D;this.applyingMatrix=true;this.matrix=B;this.fixPosition(B,K,I);this.applyingMatrix=false;this.matrix=null}}}return true},origin:function(m,s){if(f.support.csstransforms){if(typeof s==="undefined"){this.$elem.css(k,m)}else{this.$elem.css(k,m+" "+s)}return true}switch(m){case"left":m="0";break;case"right":m="100%";break;case"center":case b:m="50%"}switch(s){case"top":s="0";break;case"bottom":s="100%";break;case"center":case b:s="50%"}this.setAttr("origin",[q.test(m)?m:o(this.$elem[0],m)+"px",q.test(s)?s:o(this.$elem[0],s)+"px"]);return true},createTransformFunc:function(t,u){if(t.substr(0,7)==="reflect"){var s=u?f.matrix[t]():f.matrix.identity();return"matrix("+s.e(1,1)+", "+s.e(2,1)+", "+s.e(1,2)+", "+s.e(2,2)+", 0, 0)"}if(t=="matrix"){if(a==="-moz-"&&u[4]){u[4]=u[4]?u[4]+"px":0;u[5]=u[5]?u[5]+"px":0}}return t+"("+(f.isArray(u)?u.join(", "):u)+")"},fixPosition:function(A,x,w,C,m){var v=new f.matrix.calc(A,this.safeOuterHeight(),this.safeOuterWidth()),B=this.getAttr("origin");var u=v.originOffset(new f.matrix.V2(q.test(B[0])?parseFloat(B[0])/100*v.outerWidth:parseFloat(B[0]),q.test(B[1])?parseFloat(B[1])/100*v.outerHeight:parseFloat(B[1])));var s=v.sides();var t=this.$elem.css("position");if(t=="static"){t="relative"}var z={top:0,left:0};var y={position:t,top:(u.top+w+s.top+z.top)+"px",left:(u.left+x+s.left+z.left)+"px",zoom:1};this.$elem.css(y)}};function o(m,t){var s=c.exec(f.trim(t));if(s[3]&&s[3]!=="px"){var v="paddingBottom",u=f.style(m,v);f.style(m,v,t);t=p(m,v);f.style(m,v,u);return t}return parseFloat(t)}function p(s,t){if(s[t]!=null&&(!s.style||s.style[t]==null)){return s[t]}var m=parseFloat(f.css(s,t));return m&&m>-10000?m:0}})(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.support.csstransforms&&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(m=d.exec(j)){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.cssAngle)=="undefined"){g.cssAngle={}}g.extend(g.cssAngle,{rotate:true,skew:true,skewX:true,skewY:true});if(typeof(g.cssDefault)=="undefined"){g.cssDefault={}}g.extend(g.cssDefault,{scale:[1,1],scaleX:1,scaleY:1,matrix:[1,0,0,1,0,0],origin:["50%","50%"],reflect:[1,0,0,1,0,0],reflectX:[1,0,0,1,0,0],reflectXY:[1,0,0,1,0,0],reflectY:[1,0,0,1,0,0]});if(typeof(g.cssMultipleValues)=="undefined"){g.cssMultipleValues={}}g.extend(g.cssMultipleValues,{matrix:6,origin:{length:2,duplicate:true},reflect:6,reflectX:6,reflectXY:6,reflectY:6,scale:{length:2,duplicate:true},skew:2,translate:2});g.extend(g.cssNumber,{matrix:true,reflect:true,reflectX:true,reflectXY:true,reflectY:true,scale:true,scaleX:true,scaleY:true});g.each(g.transform.funcs,function(j,k){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,g,h,c){var d=/^([+\-]=)?([\d+.\-]+)(.*)$/;var a=e.fn.animate;e.fn.animate=function(n,k,m,l){var j=e.speed(k,m,l);if(!e.isEmptyObject(n)){if(typeof j.original==="undefined"){j.original={}}e.each(n,function(o,p){if(e.cssMultipleValues[o]||e.cssAngle[o]||(!e.cssNumber[o]&&e.inArray(o,e.transform.funcs))){j.original[o]=p.toString();n[o]=parseFloat(p)}})}return a.apply(this,[arguments[0],j])};var b="paddingBottom";function i(k,l){if(k[l]!=null&&(!k.style||k.style[l]==null)){}var j=parseFloat(e.css(k,l));return j&&j>-10000?j:0}var f=e.fx.prototype.custom;e.fx.prototype.custom=function(t,u,v){var x=e.cssMultipleValues[this.prop],o=e.cssAngle[this.prop];if(x||(!e.cssNumber[this.prop]&&e.inArray(this.prop,e.transform.funcs))){this.values=[];if(!x){x=1}var w=this.options.original[this.prop],s=e(this.elem).css(this.prop),j=e.cssDefault[this.prop]||0;if(!e.isArray(s)){s=[s]}if(!e.isArray(w)){if(e.type(w)==="string"){w=w.split(",")}else{w=[w]}}var l=x.length||x,r=0;while(w.length<l){w.push(x.duplicate?w[0]:j[r]||0);r++}var k,q,p,n=this,m=n.elem.transform;orig=e.style(n.elem,b);e.each(w,function(y,z){if(s[y]){k=s[y]}else{if(j[y]&&!x.duplicate){k=j[y]}else{if(x.duplicate){k=s[0]}else{k=0}}}if(o){k=e.angle.toDegree(k)}else{if(!e.cssNumber[n.prop]){q=d.exec(e.trim(k));if(q[3]&&q[3]!=="px"){if(q[3]==="%"){k=parseFloat(q[2])/100*m["safeOuter"+(y?"Height":"Width")]()}else{e.style(n.elem,b,k);k=i(n.elem,b);e.style(n.elem,b,orig)}}}}k=parseFloat(k);q=d.exec(e.trim(z));if(q){p=parseFloat(q[2]);v=q[3]||"px";if(o){p=e.angle.toDegree(p+v);v="deg"}else{if(!e.cssNumber[n.prop]&&v==="%"){k=(k/m["safeOuter"+(y?"Height":"Width")]())*100}else{if(!e.cssNumber[n.prop]&&v!=="px"){e.style(n.elem,b,(p||1)+v);k=((p||1)/i(n.elem,b))*k;e.style(n.elem,b,orig)}}}if(q[1]){p=((q[1]==="-="?-1:1)*p)+k}}else{p=z;v=""}n.values.push({start:k,end:p,unit:v})})}return f.apply(this,arguments)};e.fx.multipleValueStep={_default:function(j){e.each(j.values,function(k,l){j.values[k].now=l.start+((l.end-l.start)*j.pos)})}};e.each(e.transform.funcs,function(j,k){e.fx.step[k]=function(n){var m=n.elem.transform||new e.transform(n.elem),l={};if(e.cssMultipleValues[k]||(!e.cssNumber[k]&&e.inArray(k,e.transform.funcs))){(e.fx.multipleValueStep[n.prop]||e.fx.multipleValueStep._default)(n);l[n.prop]=[];e.each(n.values,function(o,p){l[n.prop].push(p.now+(e.cssNumber[n.prop]?"":p.unit))})}else{l[n.prop]=n.now+(e.cssNumber[n.prop]?"":n.unit)}m.exec(l,{preserve:true})}});e.each(["reflect","reflectX","reflectXY","reflectY"],function(k,l){var j=e.fx.step[l];e.fx.step[l]=function(p){var o=p.elem.transform||new e.transform(p.elem),n={};if(!p.initialized){p.start=p.initialized=true;var m=e.matrix[l]().elements;e.each(p.values,function(q){var r;switch(q){case 0:r=m[0];break;case 1:r=m[2];break;case 2:r=m[1];break;case 3:r=m[3];break;default:r=0}p.values[q].end=r;p.initialized=true})}(e.fx.multipleValueStep[p.prop]||e.fx.multipleValueStep._default)(p);n.matrix=[];e.each(p.values,function(q,r){n.matrix.push(r.now)});o.exec(n,{preserve:true})}})})(jQuery,this,this.document);(function(g,h,j,c){var d=180/Math.PI;var k=200/Math.PI;var f=Math.PI/180;var e=2/1.8;var i=0.9;var a=Math.PI/200;var b=/^([+\-]=)?([\d+.\-]+)(.*)$/;g.extend({angle:{runit:/(deg|g?rad)/,radianToDegree:function(l){return l*d},radianToGrad:function(l){return l*k},degreeToRadian:function(l){return l*f},degreeToGrad:function(l){return l*e},gradToDegree:function(l){return l*i},gradToRadian:function(l){return l*a},toDegree:function(m){var l=b.exec(m);if(l){m=parseFloat(l[2]);switch(l[3]||"deg"){case"grad":m=g.angle.gradToDegree(m);break;case"rad":m=g.angle.radianToDegree(m);break}return m}return 0}}})})(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
11 dist/jquery.transform-0.9.0pre.min.js
@@ -1,11 +0,0 @@
-/*
- * jQuery 2d Transform v0.9.0pre
- * http://wiki.github.com/heygrady/transform/
- *
- * Copyright 2010, Grady Kuhnline
- * Dual licensed under the MIT or GPL Version 2 licenses.
- * http://jquery.org/license
- *
- * Date: Sun Nov 7 23:14:31 2010 -0800
- */
-(function(f,g,j,c){var h=/progid:DXImageTransform\.Microsoft\.Matrix\(.*?\)/;var d=j.createElement("modernizr"),e=d.style;function n(m){return parseFloat(m)}function l(){var m={transformProperty:"",MozTransform:"-moz-",WebkitTransform:"-webkit-",OTransform:"-o-",msTransform:"-ms-"};for(var r in m){if(typeof e[r]!="undefined"){return m[r]}}return null}function q(){if(typeof(g.Modernizr)!=="undefined"){return Modernizr.csstransforms}var r=["transformProperty","WebkitTransform","MozTransform","OTransform","msTransform"];for(var m in r){if(e[r[m]]!==c){return true}}}var a=l(),i=a!==null?a+"transform":false,k=a!==null?a+"transform-origin":false;f.support.csstransforms=q();if(a=="-ms-"){i="msTransform";k="msTransformOrigin"}f.extend({transform:function(m){m.transform=this;this.$elem=f(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=i;this.transformOriginProperty=k}});f.extend(f.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)?$/}});f.fn.transform=function(m,r){return this.each(function(){var s=this.transform||new f.transform(this);if(m){s.exec(m,r)}})};f.transform.prototype={exec:function(m,r){r=f.extend(true,{forceMatrix:false,preserve:false},r);this.attr=null;if(r.preserve){m=f.extend(true,this.getAttrs(true,true),m)}else{m=f.extend(true,{},m)}this.setAttrs(m);if(f.support.csstransforms&&!r.forceMatrix){return this.execFuncs(m)}else{if(f.browser.msie||(f.support.csstransforms&&r.forceMatrix)){return this.execMatrix(m)}}return false},execFuncs:function(r){var m=[];for(var s in r){if(s=="origin"){this[s].apply(this,f.isArray(r[s])?r[s]:[r[s]])}else{if(f.inArray(s,f.transform.funcs)!=-1){m.push(this.createTransformFunc(s,r[s]))}}}this.$elem.css(i,m.join(" "));return true},execMatrix:function(t){var F,A,C;var v=this.$elem[0];function s(H){return o(v,H)}for(var w in t){if(f.matrix[w]){switch(f.type(t[w])){case"array":C=t[w];break;case"string":C=f.map(t[w].split(","),f.trim);break;default:C=[t[w]]}if(f.cssAngle[w]){C=f.map(C,f.angle.toDegree)}else{if(!f.cssNumber[w]){C=f.map(C,s)}else{C=f.map(C,n)}}A=f.matrix[w].apply(this,C);F=F?F.x(A):A}else{if(w=="origin"){C=f.isArray(t[w])?t[w]:[t[w]];this[w].apply(this,C)}}}F=F||f.matrix.identity();var G=parseFloat(F.e(1,1).toFixed(6)),E=parseFloat(F.e(2,1).toFixed(6)),D=parseFloat(F.e(1,2).toFixed(6)),B=parseFloat(F.e(2,2).toFixed(6)),y=F.rows===3?parseFloat(F.e(1,3).toFixed(6)):0,x=F.rows===3?parseFloat(F.e(2,3).toFixed(6)):0;if(f.support.csstransforms&&a==="-moz-"){this.$elem.css(i,"matrix("+G+", "+E+", "+D+", "+B+", "+y+"px, "+x+"px)")}else{if(f.support.csstransforms){this.$elem.css(i,"matrix("+G+", "+E+", "+D+", "+B+", "+y+", "+x+")")}else{if(f.browser.msie){var m=", FilterType='nearest neighbor'";var r=this.$elem[0].style;var z="progid:DXImageTransform.Microsoft.Matrix(M11="+G+", M12="+D+", M21="+E+", M22="+B+", sizingMethod='auto expand'"+m+")";var u=r.filter||f.curCSS(this.$elem[0],"filter")||"";r.filter=h.test(u)?u.replace(h,z):u?u+" "+z:z;this.applyingMatrix=true;this.matrix=F;this.fixPosition(F,y,x);this.applyingMatrix=false;this.matrix=null}}}return true},origin:function(m,r){if(f.support.csstransforms){if(typeof r==="undefined"){this.$elem.css(k,m)}else{this.$elem.css(k,m+" "+r)}return true}switch(m){case"left":m="0";break;case"right":m="100%";break;case"center":case c:m="50%"}switch(r){case"top":r="0";break;case"bottom":r="100%";break;case"center":case c:r="50%"}if(/%/.test(m)&&/%/.test(r)){this.setAttr("origin",[m,r]);return true}this.setAttr("origin",[/%/.test(m)?m:parseFloat(m)+"px",/%/.test(r)?r:parseFloat(r)+"px"]);return true},createTransformFunc:function(s,t){if(s.substr(0,7)==="reflect"){var r=t?f.matrix[s]():f.matrix.identity();return"matrix("+r.e(1,1)+", "+r.e(2,1)+", "+r.e(1,2)+", "+r.e(2,2)+", 0, 0)"}if(s=="matrix"){if(a==="-moz-"&&t[4]){t[4]=t[4]?t[4]+"px":0;t[5]=t[5]?t[5]+"px":0}}return s+"("+(f.isArray(t)?t.join(", "):t)+")"},fixPosition:function(z,w,v,B,m){var u=new f.matrix.calc(z,this.safeOuterHeight(),this.safeOuterWidth()),A=this.getAttr("origin");var t=u.originOffset(new f.matrix.V2(/%/.test(A[0])?parseFloat(A[0])/100*u.outerWidth:parseFloat(A[0]),/%/.test(A[1])?parseFloat(A[1])/100*u.outerHeight:parseFloat(A[1])));var r=u.sides();var s=this.$elem.css("position");if(s=="static"){s="relative"}var y={top:0,left:0};var x={position:s,top:(t.top+v+r.top+y.top)+"px",left:(t.left+w+r.left+y.left)+"px",zoom:1};this.$elem.css(x)}};var b=/^([\+\-]=)?([\d+.\-]+)(.*)$/;function o(m,s){var r=b.exec(f.trim(s)),u="paddingBottom",t=f.style(m,u);if(r[3]){f.style(m,u,s);s=p(m,u);f.style(m,u,t);return s}return parseFloat(s)}function p(s,t){if(s[t]!=null&&(!s.style||s.style[t]==null)){return s[t]}var m=parseFloat(f.css(s,t));return m&&m>-10000?m:0}})(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.cssAngle)=="undefined"){g.cssAngle={}}g.extend(g.cssAngle,{rotate:true,skew:true,skewX:true,skewY:true});if(typeof(g.cssDefault)=="undefined"){g.cssDefault={}}g.extend(g.cssDefault,{scale:[1,1],scaleX:1,scaleY:1,matrix:[1,0,0,1,0,0],origin:["50%","50%"],reflect:[1,0,0,1,0,0],reflectX:[1,0,0,1,0,0],reflectXY:[1,0,0,1,0,0],reflectY:[1,0,0,1,0,0]});if(typeof(g.cssMultipleValues)=="undefined"){g.cssMultipleValues={}}g.extend(g.cssMultipleValues,{matrix:6,origin:{length:2,duplicate:true},reflect:6,reflectX:6,reflectXY:6,reflectY:6,scale:{length:2,duplicate:true},skew:2,translate:2});g.extend(g.cssNumber,{matrix:true,reflect:true,reflectX:true,reflectXY:true,reflectY:true,scale:true,scaleX:true,scaleY:true});g.each(g.transform.funcs,function(j,k){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,g,h,c){var d=/^([+\-]=)?([\d+.\-]+)(.*)$/;var a=e.fn.animate;e.fn.animate=function(n,k,m,l){var j=e.speed(k,m,l);if(!e.isEmptyObject(n)){if(typeof j.original==="undefined"){j.original={}}e.each(n,function(o,p){if(e.cssMultipleValues[o]||e.cssAngle[o]||(!e.cssNumber[o]&&e.inArray(o,e.transform.funcs))){j.original[o]=p.toString();n[o]=parseFloat(p)}})}return a.apply(this,[arguments[0],j])};var b="paddingBottom";function i(k,l){if(k[l]!=null&&(!k.style||k.style[l]==null)){}var j=parseFloat(e.css(k,l));return j&&j>-10000?j:0}var f=e.fx.prototype.custom;e.fx.prototype.custom=function(t,u,v){var x=e.cssMultipleValues[this.prop],n=e.cssAngle[this.prop];if(x||(!e.cssNumber[this.prop]&&e.inArray(this.prop,e.transform.funcs))){this.values=[];if(!x){x=1}var w=this.options.original[this.prop],r=e(this.elem).css(this.prop),j=e.cssDefault[this.prop]||0;if(!e.isArray(r)){r=[r]}if(!e.isArray(w)){if(e.type(w)==="string"){w=w.split(",")}else{w=[w]}}var l=x.length||x,q=0;while(w.length<l){w.push(x.duplicate?w[0]:j[q]||0);q++}var k,p,o,m=this,s=e.style(m.elem,b);e.each(w,function(y,z){if(r[y]){k=r[y]}else{if(j[y]&&!x.duplicate){k=j[y]}else{if(x.duplicate){k=r[0]}else{k=0}}}if(n){k=e.angle.toDegree(k)}else{if(!e.cssNumber[m.prop]){p=d.exec(e.trim(k));if(p[3]){e.style(m.elem,b,k);k=i(m.elem,b);e.style(m.elem,b,s)}}else{k=parseFloat(k)}}p=d.exec(e.trim(z));if(p){o=parseFloat(p[2]);v=p[3]||"px";if(n){o=e.angle.toDegree(o+v);v="deg"}else{if(!e.cssNumber[m.prop]&&v!=="px"){e.style(m.elem,b,(o||1)+v);k=((o||1)/i(m.elem,b))*k;e.style(m.elem,b,s)}}if(p[1]){o=((p[1]==="-="?-1:1)*o)+k}}else{o=z;v=""}m.values.push({start:k,end:o,unit:v})})}return f.apply(this,arguments)};e.fx.multipleValueStep={_default:function(j){e.each(j.values,function(k,l){j.values[k].now=l.start+((l.end-l.start)*j.pos)})}};e.each(e.transform.funcs,function(j,k){e.fx.step[k]=function(n){var m=n.elem.transform||new e.transform(n.elem),l={};if(e.cssMultipleValues[k]||(!e.cssNumber[k]&&e.inArray(k,e.transform.funcs))){(e.fx.multipleValueStep[n.prop]||e.fx.multipleValueStep._default)(n);l[n.prop]=[];e.each(n.values,function(o,p){l[n.prop].push(p.now+(e.cssNumber[n.prop]?"":p.unit))})}else{l[n.prop]=n.now+(e.cssNumber[n.prop]?"":n.unit)}m.exec(l,{preserve:true})}});e.each(["reflect","reflectX","reflectXY","reflectY"],function(k,l){var j=e.fx.step[l];e.fx.step[l]=function(p){var o=p.elem.transform||new e.transform(p.elem),n={};if(!p.initialized){p.start=p.initialized=true;var m=e.matrix[l]().elements;e.each(p.values,function(q){var r;switch(q){case 0:r=m[0];break;case 1:r=m[2];break;case 2:r=m[1];break;case 3:r=m[3];break;default:r=0}p.values[q].end=r;p.initialized=true})}(e.fx.multipleValueStep[p.prop]||e.fx.multipleValueStep._default)(p);n.matrix=[];e.each(p.values,function(q,r){n.matrix.push(r.now)});o.exec(n,{preserve:true})}})})(jQuery,this,this.document);(function(g,h,j,c){var d=180/Math.PI;var k=200/Math.PI;var f=Math.PI/180;var e=2/1.8;var i=0.9;var a=Math.PI/200;var b=/^([+\-]=)?([\d+.\-]+)(.*)$/;g.extend({angle:{runit:/(deg|g?rad)/,radianToDegree:function(l){return l*d},radianToGrad:function(l){return l*k},degreeToRadian:function(l){return l*f},degreeToGrad:function(l){return l*e},gradToDegree:function(l){return l*i},gradToRadian:function(l){return l*a},toDegree:function(m){var l=b.exec(m);if(l){m=parseFloat(l[2]);switch(l[3]||"deg"){case"grad":m=g.angle.gradToDegree(m);break;case"rad":m=g.angle.radianToDegree(m);break}return m}return 0}}})})(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
125 dist/jquery.transform.js
@@ -1,12 +1,12 @@
/*!
- * jQuery 2d Transform v0.9.0pre
+ * jQuery 2d Transform v0.9.0
* http://wiki.github.com/heygrady/transform/
*
* Copyright 2010, Grady Kuhnline
* Dual licensed under the MIT or GPL Version 2 licenses.
* http://jquery.org/license
*
- * Date: Sun Nov 7 23:14:31 2010 -0800
+ * Date: Sun Nov 14 13:45:35 2010 -0800
*/
///////////////////////////////////////////////////////
// Transform
@@ -15,7 +15,9 @@
/**
* @var Regex identify the matrix filter in IE
*/
- var rmatrix = /progid:DXImageTransform\.Microsoft\.Matrix\(.*?\)/;
+ var rmatrix = /progid:DXImageTransform\.Microsoft\.Matrix\(.*?\)/,
+ rfxnum = /^([\+\-]=)?([\d+.\-]+)(.*)$/,
+ rperc = /%/;
// Steal some code from Modernizr
var m = document.createElement( 'modernizr' ),
@@ -119,30 +121,7 @@
/**
* @var Array list of all valid transform functions
*/
- funcs: ['matrix', 'origin', 'reflect', 'reflectX', 'reflectXY', 'reflectY', 'rotate', 'scale', 'scaleX', 'scaleY', 'skew', 'skewX', 'skewY', 'translate', 'translateX', 'translateY'],
-
- //TODO: these regexes are not long for this world
- rfunc: {
- /**
- * @var Regex identifies functions that require an angle unit
- */
- angle: /^rotate|skew[X|Y]?$/,
-
- /**
- * @var Regex identifies functions that require a length unit
- */
- length: /^origin|translate[X|Y]?$/,
-
- /**
- * @var Regex identifies functions that do not require a unit
- */
- scale: /^scale[X|Y]?$/,
-
- /**
- * @var Regex reflection functions
- */
- reflect: /^reflect(XY|X|Y)?$/
- }
+ funcs: ['matrix', 'origin', 'reflect', 'reflectX', 'reflectXY', 'reflectY', 'rotate', 'scale', 'scaleX', 'scaleY', 'skew', 'skewX', 'skewY', 'translate', 'translateX', 'translateY']
});
/**
@@ -225,18 +204,27 @@
tempMatrix,
args;
- var elem = this.$elem[0];
- function normalPixels(val) {
+ var elem = this.$elem[0],
+ _this = this;
+ function normalPixels(val, i) {
+ if (rperc.test(val)) {
+ // this really only applies to translation
+ return parseFloat(val) / 100 * _this['safeOuter' + (i ? 'Height' : 'Width')]();
+ }
return toPx(elem, val);
}
+ var rtranslate = /translate[X|Y]?/,
+ trans = [];
+
for (var func in funcs) {
+ switch ($.type(funcs[func])) {
+ case 'array': args = funcs[func]; break;
+ case 'string': args = $.map(funcs[func].split(','), $.trim); break;
+ default: args = [funcs[func]];
+ }
+
if ($.matrix[func]) {
- switch ($.type(funcs[func])) {
- case 'array': args = funcs[func]; break;
- case 'string': args = $.map(funcs[func].split(','), $.trim);break;
- default: args = [funcs[func]];
- }
if ($.cssAngle[func]) {
// normalize on degrees
@@ -249,20 +237,23 @@
args = $.map(args, stripUnits);
}
- // TODO: translation and origin should be applied last
- // TODO: should hold translations until the extreme end
tempMatrix = $.matrix[func].apply(this, args);
- matrix = matrix ? matrix.x(tempMatrix) : tempMatrix;
+ if (rtranslate.test(func)) {
+ //defer translation
+ trans.push(tempMatrix);
+ } else {
+ matrix = matrix ? matrix.x(tempMatrix) : tempMatrix;
+ }
} else if (func == 'origin') {
- //TODO: this is a dumb way to handle the origin for a matrix
- args = $.isArray(funcs[func]) ? funcs[func] : [funcs[func]];
this[func].apply(this, args);
}
}
// check that we have a matrix
- // TODO: This will result in a filter being needlessly set in IE
matrix = matrix || $.matrix.identity();
+
+ // Apply translation
+ $.each(trans, function(i, val) { matrix = matrix.x(val); });
// pull out the relevant values
var a = parseFloat(matrix.e(1,1).toFixed(6)),
@@ -336,17 +327,12 @@
case undefined: y = '50%'; //TODO: does this work?
}
- // store percentages directly
- if (/%/.test(x) && /%/.test(y)) {
- this.setAttr('origin', [x, y]);
- return true;
- }
-
// store mixed values with units, assumed pixels
this.setAttr('origin', [
- /%/.test(x) ? x : parseFloat(x) + 'px',
- /%/.test(y) ? y : parseFloat(y) + 'px'
+ rperc.test(x) ? x : toPx(this.$elem[0], x) + 'px',
+ rperc.test(y) ? y : toPx(this.$elem[0], y) + 'px'
]);
+ //console.log(this.getAttr('origin'));
return true;
},
@@ -385,11 +371,11 @@
// now we need to fix it!
var calc = new $.matrix.calc(matrix, this.safeOuterHeight(), this.safeOuterWidth()),
origin = this.getAttr('origin'); // mixed percentages and px
-
+
// translate a 0, 0 origin to the current origin
var offset = calc.originOffset(new $.matrix.V2(
- /%/.test(origin[0]) ? parseFloat(origin[0])/100*calc.outerWidth : parseFloat(origin[0]),
- /%/.test(origin[1]) ? parseFloat(origin[1])/100*calc.outerHeight : parseFloat(origin[1])
+ rperc.test(origin[0]) ? parseFloat(origin[0])/100*calc.outerWidth : parseFloat(origin[0]),
+ rperc.test(origin[1]) ? parseFloat(origin[1])/100*calc.outerHeight : parseFloat(origin[1])
));
// IE glues the top-most and left-most pixels of the transformed object to top/left of the original object
@@ -423,13 +409,13 @@
* @param string func
* @param Mixed value
*/
- var rfxnum = /^([\+\-]=)?([\d+.\-]+)(.*)$/;
function toPx(elem, val) {
- var parts = rfxnum.exec($.trim(val)),
- prop = 'paddingBottom',
- orig = $.style( elem, prop );
-
- if (parts[3]) {
+ var parts = rfxnum.exec($.trim(val));
+
+ if (parts[3] && parts[3] !== 'px') {
+ var prop = 'paddingBottom',
+ orig = $.style( elem, prop );
+
$.style( elem, prop, val );
val = cur( elem, prop );
$.style( elem, prop, orig );
@@ -479,7 +465,7 @@
safeOuterLength: function(dim) {
var funcName = 'outer' + (dim == 'width' ? 'Width' : 'Height');
- if ($.browser.msie) {
+ if (!$.support.csstransforms && $.browser.msie) {
// make the variables more generic
dim = dim == 'width' ? 'width' : 'height';
@@ -615,8 +601,7 @@
// pull from a local variable to look it up
var transform = this.attr || this.$elem.attr(attr);
-
- if (!transform || transform.indexOf(func) > -1) {
+ if (!transform || transform.indexOf(func) == -1) {
// we don't have any existing values, save it
// we don't have this function yet, save it
this.attr = $.trim(transform + ' ' + func + '(' + value + ')');
@@ -627,7 +612,7 @@
// regex split
rfuncvalue.lastIndex = 0; // reset the regex pointer
- while ((result = rfuncvalue.exec(transform)) !== null) {
+ while (parts = rfuncvalue.exec(transform)) {
if (func == parts[1]) {
funcs.push(func + '(' + value + ')');
} else {
@@ -867,6 +852,7 @@
// calculate a start, end and unit for each new value
var start, parts, end, //unit,
fx = this,
+ transform = fx.elem.transform;
orig = $.style(fx.elem, prop);
$.each(values, function(i, val) {
@@ -886,14 +872,17 @@
start = $.angle.toDegree(start);
} else if (!$.cssNumber[fx.prop]) {
parts = rfxnum.exec($.trim(start));
- if (parts[3]) {
- $.style( fx.elem, prop, start);
- start = cur(fx.elem, prop);
- $.style( fx.elem, prop, orig);
+ if (parts[3] && parts[3] !== 'px') {
+ if (parts[3] === '%') {
+ start = parseFloat( parts[2] ) / 100 * transform['safeOuter' + (i ? 'Height' : 'Width')]();
+ } else {
+ $.style( fx.elem, prop, start);
+ start = cur(fx.elem, prop);
+ $.style( fx.elem, prop, orig);
+ }
}
- } else {
- start = parseFloat(start);
}
+ start = parseFloat(start);
// parse the value with a regex
parts = rfxnum.exec($.trim(val));
@@ -906,6 +895,8 @@
if (angle) {
end = $.angle.toDegree(end + unit);
unit = 'deg';
+ } else if (!$.cssNumber[fx.prop] && unit === '%') {
+ start = (start / transform['safeOuter' + (i ? 'Height' : 'Width')]()) * 100;
} else if (!$.cssNumber[fx.prop] && unit !== 'px') {
$.style( fx.elem, prop, (end || 1) + unit);
start = ((end || 1) / cur(fx.elem, prop)) * start;
View
18 src/jquery.transform.animate.js
@@ -95,6 +95,7 @@
// calculate a start, end and unit for each new value
var start, parts, end, //unit,
fx = this,
+ transform = fx.elem.transform;
orig = $.style(fx.elem, prop);
$.each(values, function(i, val) {
@@ -114,14 +115,17 @@
start = $.angle.toDegree(start);
} else if (!$.cssNumber[fx.prop]) {
parts = rfxnum.exec($.trim(start));
- if (parts[3]) {
- $.style( fx.elem, prop, start);
- start = cur(fx.elem, prop);
- $.style( fx.elem, prop, orig);
+ if (parts[3] && parts[3] !== 'px') {
+ if (parts[3] === '%') {
+ start = parseFloat( parts[2] ) / 100 * transform['safeOuter' + (i ? 'Height' : 'Width')]();
+ } else {
+ $.style( fx.elem, prop, start);
+ start = cur(fx.elem, prop);
+ $.style( fx.elem, prop, orig);
+ }
}
- } else {
- start = parseFloat(start);
}
+ start = parseFloat(start);
// parse the value with a regex
parts = rfxnum.exec($.trim(val));
@@ -134,6 +138,8 @@
if (angle) {
end = $.angle.toDegree(end + unit);
unit = 'deg';
+ } else if (!$.cssNumber[fx.prop] && unit === '%') {
+ start = (start / transform['safeOuter' + (i ? 'Height' : 'Width')]()) * 100;
} else if (!$.cssNumber[fx.prop] && unit !== 'px') {
$.style( fx.elem, prop, (end || 1) + unit);
start = ((end || 1) / cur(fx.elem, prop)) * start;
View
5 src/jquery.transform.attributes.js
@@ -42,8 +42,7 @@
// pull from a local variable to look it up
var transform = this.attr || this.$elem.attr(attr);
-
- if (!transform || transform.indexOf(func) > -1) {
+ if (!transform || transform.indexOf(func) == -1) {
// we don't have any existing values, save it
// we don't have this function yet, save it
this.attr = $.trim(transform + ' ' + func + '(' + value + ')');
@@ -54,7 +53,7 @@
// regex split
rfuncvalue.lastIndex = 0; // reset the regex pointer
- while ((result = rfuncvalue.exec(transform)) !== null) {
+ while (parts = rfuncvalue.exec(transform)) {
if (func == parts[1]) {
funcs.push(func + '(' + value + ')');
} else {
View
98 src/jquery.transform.js
@@ -15,7 +15,9 @@
/**
* @var Regex identify the matrix filter in IE
*/
- var rmatrix = /progid:DXImageTransform\.Microsoft\.Matrix\(.*?\)/;
+ var rmatrix = /progid:DXImageTransform\.Microsoft\.Matrix\(.*?\)/,
+ rfxnum = /^([\+\-]=)?([\d+.\-]+)(.*)$/,
+ rperc = /%/;
// Steal some code from Modernizr
var m = document.createElement( 'modernizr' ),
@@ -119,30 +121,7 @@
/**
* @var Array list of all valid transform functions
*/
- funcs: ['matrix', 'origin', 'reflect', 'reflectX', 'reflectXY', 'reflectY', 'rotate', 'scale', 'scaleX', 'scaleY', 'skew', 'skewX', 'skewY', 'translate', 'translateX', 'translateY'],
-
- //TODO: these regexes are not long for this world
- rfunc: {
- /**
- * @var Regex identifies functions that require an angle unit
- */
- angle: /^rotate|skew[X|Y]?$/,
-
- /**
- * @var Regex identifies functions that require a length unit
- */
- length: /^origin|translate[X|Y]?$/,
-
- /**
- * @var Regex identifies functions that do not require a unit
- */
- scale: /^scale[X|Y]?$/,
-
- /**
- * @var Regex reflection functions
- */
- reflect: /^reflect(XY|X|Y)?$/
- }
+ funcs: ['matrix', 'origin', 'reflect', 'reflectX', 'reflectXY', 'reflectY', 'rotate', 'scale', 'scaleX', 'scaleY', 'skew', 'skewX', 'skewY', 'translate', 'translateX', 'translateY']
});
/**
@@ -225,18 +204,27 @@
tempMatrix,
args;
- var elem = this.$elem[0];
- function normalPixels(val) {
+ var elem = this.$elem[0],
+ _this = this;
+ function normalPixels(val, i) {
+ if (rperc.test(val)) {
+ // this really only applies to translation
+ return parseFloat(val) / 100 * _this['safeOuter' + (i ? 'Height' : 'Width')]();
+ }
return toPx(elem, val);
}
+ var rtranslate = /translate[X|Y]?/,
+ trans = [];
+
for (var func in funcs) {
+ switch ($.type(funcs[func])) {
+ case 'array': args = funcs[func]; break;
+ case 'string': args = $.map(funcs[func].split(','), $.trim); break;
+ default: args = [funcs[func]];
+ }
+
if ($.matrix[func]) {
- switch ($.type(funcs[func])) {
- case 'array': args = funcs[func]; break;
- case 'string': args = $.map(funcs[func].split(','), $.trim);break;
- default: args = [funcs[func]];
- }
if ($.cssAngle[func]) {
// normalize on degrees
@@ -249,20 +237,23 @@
args = $.map(args, stripUnits);
}
- // TODO: translation and origin should be applied last
- // TODO: should hold translations until the extreme end
tempMatrix = $.matrix[func].apply(this, args);
- matrix = matrix ? matrix.x(tempMatrix) : tempMatrix;
+ if (rtranslate.test(func)) {
+ //defer translation
+ trans.push(tempMatrix);
+ } else {
+ matrix = matrix ? matrix.x(tempMatrix) : tempMatrix;
+ }
} else if (func == 'origin') {
- //TODO: this is a dumb way to handle the origin for a matrix
- args = $.isArray(funcs[func]) ? funcs[func] : [funcs[func]];
this[func].apply(this, args);
}
}
// check that we have a matrix
- // TODO: This will result in a filter being needlessly set in IE
matrix = matrix || $.matrix.identity();
+
+ // Apply translation
+ $.each(trans, function(i, val) { matrix = matrix.x(val); });
// pull out the relevant values
var a = parseFloat(matrix.e(1,1).toFixed(6)),
@@ -336,17 +327,12 @@
case undefined: y = '50%'; //TODO: does this work?
}
- // store percentages directly
- if (/%/.test(x) && /%/.test(y)) {
- this.setAttr('origin', [x, y]);
- return true;
- }
-
// store mixed values with units, assumed pixels
this.setAttr('origin', [
- /%/.test(x) ? x : parseFloat(x) + 'px',
- /%/.test(y) ? y : parseFloat(y) + 'px'
+ rperc.test(x) ? x : toPx(this.$elem[0], x) + 'px',
+ rperc.test(y) ? y : toPx(this.$elem[0], y) + 'px'
]);
+ //console.log(this.getAttr('origin'));
return true;
},
@@ -385,11 +371,11 @@
// now we need to fix it!
var calc = new $.matrix.calc(matrix, this.safeOuterHeight(), this.safeOuterWidth()),
origin = this.getAttr('origin'); // mixed percentages and px
-
+
// translate a 0, 0 origin to the current origin
var offset = calc.originOffset(new $.matrix.V2(
- /%/.test(origin[0]) ? parseFloat(origin[0])/100*calc.outerWidth : parseFloat(origin[0]),
- /%/.test(origin[1]) ? parseFloat(origin[1])/100*calc.outerHeight : parseFloat(origin[1])
+ rperc.test(origin[0]) ? parseFloat(origin[0])/100*calc.outerWidth : parseFloat(origin[0]),
+ rperc.test(origin[1]) ? parseFloat(origin[1])/100*calc.outerHeight : parseFloat(origin[1])
));
// IE glues the top-most and left-most pixels of the transformed object to top/left of the original object
@@ -423,13 +409,13 @@
* @param string func
* @param Mixed value
*/
- var rfxnum = /^([\+\-]=)?([\d+.\-]+)(.*)$/;
function toPx(elem, val) {
- var parts = rfxnum.exec($.trim(val)),
- prop = 'paddingBottom',
- orig = $.style( elem, prop );
-
- if (parts[3]) {
+ var parts = rfxnum.exec($.trim(val));
+
+ if (parts[3] && parts[3] !== 'px') {
+ var prop = 'paddingBottom',
+ orig = $.style( elem, prop );
+
$.style( elem, prop, val );
val = cur( elem, prop );
$.style( elem, prop, orig );
@@ -479,7 +465,7 @@
safeOuterLength: function(dim) {
var funcName = 'outer' + (dim == 'width' ? 'Width' : 'Height');
- if ($.browser.msie) {
+ if (!$.support.csstransforms && $.browser.msie) {
// make the variables more generic
dim = dim == 'width' ? 'width' : 'height';
View
86 test/test2.html
@@ -235,9 +235,9 @@
break;
case 5:
$elem.transform({"rotate": '13deg'});
- $anim.animate({"rotate": 13, "reflectXY": false}, {
+ $anim.animate({"rotate": '13deg', "reflectXY": false}, {
'complete': function(){
- $anim.transform({"rotate": 13});
+ $anim.transform({"rotate": '13deg'});
next(5);
}
});
@@ -245,33 +245,33 @@
break;
case 6:
$elem.transform({"rotate": '-13deg'});
- $anim.animate({"rotate": -13}, {
+ $anim.animate({"rotate": '-13deg'}, {
'complete': function(){
- $anim.transform({"rotate": -13});
+ $anim.transform({"rotate": '-13deg'});
next(6);
}
});
$text.text('rotate: -13');
break;
case 7:
- $elem.transform({"rotate": 195});
- $anim.animate({"rotate": 195}, {
+ $elem.transform({"rotate": '195deg'});
+ $anim.animate({"rotate": '195deg'}, {
'complete': function(){
- $anim.transform({"rotate": 195});
+ $anim.transform({"rotate": '195deg'});
next(7);
}
});
- $text.text('rotate: 195');
+ $text.text('rotate: 195deg');
break;
case 8:
- $elem.transform({"rotate": -195});
- $anim.animate({"rotate": -195}, {
+ $elem.transform({"rotate": '-195deg'});
+ $anim.animate({"rotate": '-195deg'}, {
'complete': function(){
- $anim.transform({"rotate": -195});
+ $anim.transform({"rotate": '-195deg'});
next(8);
}
});
- $text.text('rotate : -195');
+ $text.text('rotate : -195deg');
break;
case 9:
$elem.transform({"scale": .75});
@@ -314,84 +314,84 @@
$text.text('scaleY : .75');
break;
case 13:
- $elem.transform({"skew": [13, 0]});
- $anim.animate({"skew": '13, 0', "scaleY": 1}, {
+ $elem.transform({"skew": ['13deg', 0]});
+ $anim.animate({"skew": '13deg, 0', "scaleY": 1}, {
'complete': function(){
- $anim.transform({"skew": [13, 0]});
+ $anim.transform({"skew": ['13deg', 0]});
next(13);
}
});
- $text.text('skew : 13');
+ $text.text('skew : 13deg');
break;
case 14:
- $elem.transform({"skew": ['13', 13]});
- $anim.animate({"skew": '13, 13'}, {
+ $elem.transform({"skew": ['13deg', '13deg']});
+ $anim.animate({"skew": '13deg, 13deg'}, {
'complete': function(){
- $anim.transform({"skew": [13, 13]});
+ $anim.transform({"skew": ['13deg', '13deg']});
next(14);
}
});
- $text.text('skew : [13, 13]');
+ $text.text('skew : [13deg, 13deg]');
break;
case 15:
- $elem.transform({"skewX": '13'});
- $anim.animate({"skewX": '13', "skew": '0, 0'}, {
+ $elem.transform({"skewX": '13deg'});
+ $anim.animate({"skewX": '13deg', "skew": '0, 0'}, {
'complete': function(){
- $anim.transform({"skewX": 13});
+ $anim.transform({"skewX": '13deg'});
next(15);
}
});
- $text.text('skewX : 13');
+ $text.text('skewX : 13deg');
break;
case 16:
- $elem.transform({"skewY": 13});
- $anim.animate({"skewY": 13, "skewX": 0}, {
+ $elem.transform({"skewY": '13'});
+ $anim.animate({"skewY": '13deg', "skewX": 0}, {
'complete': function(){
- $anim.transform({"skewY": 13});
+ $anim.transform({"skewY": '13deg'});
next(16);
}
});
$text.text('skewY : 13');
break;
case 17:
- $elem.transform({"translate": [13, 0]});
- $anim.animate({"translate": '13, 0', "skewY": 0}, {
+ $elem.transform({"translate": ['13px', 0]});
+ $anim.animate({"translate": '13px, 0', "skewY": 0}, {
'complete': function(){
- $anim.transform({"translate": [13, 0]});
+ $anim.transform({"translate": ['13px', 0]});
next(17);
}
});
- $text.text('translate : 13');
+ $text.text('translate : 13px');
break;
case 18:
- $elem.transform({"translate": [13, 13]});
- $anim.animate({"translate": '13, 13'}, {
+ $elem.transform({"translate": ['13px', '13px']});
+ $anim.animate({"translate": '13px, 13px'}, {
'complete': function(){
- $anim.transform({"translate": [13, 13]});
+ $anim.transform({"translate": ['13px', '13px']});
next(18);
}
});
- $text.text('translate : [13, 13]');
+ $text.text('translate : [13px, 13px]');
break;
case 19:
- $elem.transform({"translateX": 13});
- $anim.animate({"translateX": 13, "translate": '0, 0'}, {
+ $elem.transform({"translateX": '13px'});
+ $anim.animate({"translateX": '13px', "translate": '0, 0'}, {
'complete': function(){
- $anim.transform({"translateX": 13});
+ $anim.transform({"translateX": '13px'});
next(19);
}
});
- $text.text('translateX : 13');
+ $text.text('translateX : 13px');
break;
case 20:
- $elem.transform({"translateY": 13});
- $anim.animate({"translateY": 13, "translateX": 0}, {
+ $elem.transform({"translateY": '13px'});
+ $anim.animate({"translateY": '13px', "translateX": 0}, {
'complete': function(){
- $anim.transform({"translateY": 13});
+ $anim.transform({"translateY": '13px'});
next(20);
}
});
- $text.text('translateY : 13');
+ $text.text('translateY : 13px');
break;
default:
step = 0;
View
2  version.txt
@@ -1 +1 @@
-0.9.0pre
+0.9.0
Please sign in to comment.
Something went wrong with that request. Please try again.