aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/styles-controller.js
diff options
context:
space:
mode:
Diffstat (limited to 'js/controllers/styles-controller.js')
-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 703d61f4..11d53ac0 100755
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -1329,33 +1329,68 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1329 1329
1330 ///// Get Matrix From Element 1330 ///// Get Matrix From Element
1331 ///// Returns the matrix from an element's -webkit-transform 1331 ///// Returns the matrix from an element's -webkit-transform
1332 //// TODO - This routine should eventually check for other transform styles, i.e., rotateX, translateZ, etc.
1333 1332
1334 getMatrixFromElement : { 1333 getMatrixFromElement : {
1335 value: function(element, isStage) { 1334 value: function(element, isStage) {
1336 isStage = false; 1335 isStage = false;
1337 var xformStr = this.getElementStyle(element, "-webkit-transform", true, isStage), 1336 var xformStr = this.getElementStyle(element, "-webkit-transform", true, isStage),
1338 mat; 1337 mat,
1338 index1,
1339 index2,
1340 substr,
1341 numArray,
1342 nNums,
1343 i;
1339 1344
1340 if (xformStr) { 1345 if (xformStr) {
1341 var index1 = xformStr.indexOf( "matrix3d("); 1346 // Check for 3d matrix
1347 index1 = xformStr.indexOf( "matrix3d(");
1348 // If style does not contain 'matrix3d', try computed matrix/matrix3d from rotateY, translateZ, etc.
1349 if((index1 === -1) && element.ownerDocument.defaultView) {
1350 xformStr = element.ownerDocument.defaultView.getComputedStyle(element).getPropertyValue("-webkit-transform");
1351 index1 = xformStr.indexOf( "matrix3d(");
1352 }
1342 if (index1 >= 0) { 1353 if (index1 >= 0) {
1343 index1 += 9; // do not include 'matrix3d(' 1354 index1 += 9; // do not include 'matrix3d('
1344 var index2 = xformStr.indexOf( ")", index1 ); 1355 index2 = xformStr.indexOf( ")", index1 );
1345 if (index2 >= 0) { 1356 if (index2 >= 0) {
1346 var substr = xformStr.substr( index1, (index2-index1)); 1357 substr = xformStr.substr( index1, (index2-index1));
1347 if (substr && (substr.length > 0)) { 1358 if (substr && (substr.length > 0)) {
1348 var numArray = substr.split(','); 1359 numArray = substr.split(',');
1349 var nNums = numArray.length; 1360 nNums = numArray.length;
1350 if (nNums == 16) { 1361 if (nNums == 16) {
1351 // gl-matrix wants row order 1362 // gl-matrix wants row order
1352 mat = numArray; 1363 mat = numArray;
1353 for (var i=0; i<16; i++) { 1364 for (i=0; i<16; i++) {
1354 mat[i] = Number( mat[i] ); 1365 mat[i] = Number( mat[i] );
1355 } 1366 }
1356 } 1367 }
1357 } 1368 }
1358 } 1369 }
1370 } else {
1371 // Check for 2d matrix
1372 index1 = xformStr.indexOf( "matrix(");
1373 if (index1 >= 0) {
1374 index1 += 7; // do not include 'matrix('
1375 index2 = xformStr.indexOf( ")", index1 );
1376 if (index2 >= 0) {
1377 substr = xformStr.substr( index1, (index2-index1));
1378 if (substr && (substr.length > 0)) {
1379 numArray = substr.split(',');
1380 nNums = numArray.length;
1381 if (nNums === 6) {
1382 // gl-matrix wants row order
1383 mat = Matrix.I(4);
1384 mat[0] = Number(numArray[0]);
1385 mat[1] = Number(numArray[1]);
1386 mat[4] = Number(numArray[2]);
1387 mat[5] = Number(numArray[3]);
1388 mat[12] = Number(numArray[4]);
1389 mat[13] = Number(numArray[5]);
1390 }
1391 }
1392 }
1393 }
1359 } 1394 }
1360 } 1395 }
1361 return mat; 1396 return mat;