aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
authorJose Antonio Marquez2012-07-20 09:52:03 -0700
committerJose Antonio Marquez2012-07-20 09:52:03 -0700
commit5d82978e9a0e0daf7c457ff87be95a3b4301999e (patch)
tree906f908fef755b8e0f57ab7a0d9ce348c398958b /js/controllers
parenta8b7648d2c1305eb068d42ebde9b042ee6de72ab (diff)
parent9053e2037821a5c8405fabb74db9635deacfe8d5 (diff)
downloadninja-5d82978e9a0e0daf7c457ff87be95a3b4301999e.tar.gz
Merge branch 'refs/heads/Ninja-Master' into Document
Diffstat (limited to 'js/controllers')
-rwxr-xr-xjs/controllers/styles-controller.js51
1 files changed, 43 insertions, 8 deletions
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index 89a389a4..b0db1b6a 100755
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -1292,33 +1292,68 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1292 1292
1293 ///// Get Matrix From Element 1293 ///// Get Matrix From Element
1294 ///// Returns the matrix from an element's -webkit-transform 1294 ///// Returns the matrix from an element's -webkit-transform
1295 //// TODO - This routine should eventually check for other transform styles, i.e., rotateX, translateZ, etc.
1296 1295
1297 getMatrixFromElement : { 1296 getMatrixFromElement : {
1298 value: function(element, isStage) { 1297 value: function(element, isStage) {
1299 isStage = false; 1298 isStage = false;
1300 var xformStr = this.getElementStyle(element, "-webkit-transform", true, isStage), 1299 var xformStr = this.getElementStyle(element, "-webkit-transform", true, isStage),
1301 mat; 1300 mat,
1301 index1,
1302 index2,
1303 substr,
1304 numArray,
1305 nNums,
1306 i;
1302 1307
1303 if (xformStr) { 1308 if (xformStr) {
1304 var index1 = xformStr.indexOf( "matrix3d("); 1309 // Check for 3d matrix
1310 index1 = xformStr.indexOf( "matrix3d(");
1311 // If style does not contain 'matrix3d', try computed matrix/matrix3d from rotateY, translateZ, etc.
1312 if((index1 === -1) && element.ownerDocument.defaultView) {
1313 xformStr = element.ownerDocument.defaultView.getComputedStyle(element).getPropertyValue("-webkit-transform");
1314 index1 = xformStr.indexOf( "matrix3d(");
1315 }
1305 if (index1 >= 0) { 1316 if (index1 >= 0) {
1306 index1 += 9; // do not include 'matrix3d(' 1317 index1 += 9; // do not include 'matrix3d('
1307 var index2 = xformStr.indexOf( ")", index1 ); 1318 index2 = xformStr.indexOf( ")", index1 );
1308 if (index2 >= 0) { 1319 if (index2 >= 0) {
1309 var substr = xformStr.substr( index1, (index2-index1)); 1320 substr = xformStr.substr( index1, (index2-index1));
1310 if (substr && (substr.length > 0)) { 1321 if (substr && (substr.length > 0)) {
1311 var numArray = substr.split(','); 1322 numArray = substr.split(',');
1312 var nNums = numArray.length; 1323 nNums = numArray.length;
1313 if (nNums == 16) { 1324 if (nNums == 16) {
1314 // gl-matrix wants row order 1325 // gl-matrix wants row order
1315 mat = numArray; 1326 mat = numArray;
1316 for (var i=0; i<16; i++) { 1327 for (i=0; i<16; i++) {
1317 mat[i] = Number( mat[i] ); 1328 mat[i] = Number( mat[i] );
1318 } 1329 }
1319 } 1330 }
1320 } 1331 }
1321 } 1332 }
1333 } else {
1334 // Check for 2d matrix
1335 index1 = xformStr.indexOf( "matrix(");
1336 if (index1 >= 0) {
1337 index1 += 7; // do not include 'matrix('
1338 index2 = xformStr.indexOf( ")", index1 );
1339 if (index2 >= 0) {
1340 substr = xformStr.substr( index1, (index2-index1));
1341 if (substr && (substr.length > 0)) {
1342 numArray = substr.split(',');
1343 nNums = numArray.length;
1344 if (nNums === 6) {
1345 // gl-matrix wants row order
1346 mat = Matrix.I(4);
1347 mat[0] = Number(numArray[0]);
1348 mat[1] = Number(numArray[1]);
1349 mat[4] = Number(numArray[2]);
1350 mat[5] = Number(numArray[3]);
1351 mat[12] = Number(numArray[4]);
1352 mat[13] = Number(numArray[5]);
1353 }
1354 }
1355 }
1356 }
1322 } 1357 }
1323 } 1358 }
1324 return mat; 1359 return mat;