aboutsummaryrefslogtreecommitdiff
path: root/js/controllers
diff options
context:
space:
mode:
authorValerio Virgillito2012-07-19 11:56:08 -0700
committerValerio Virgillito2012-07-19 11:56:08 -0700
commitc97f806fceb2a2e3c668b965e4f8e6fc047a3d9a (patch)
tree8e8d87b31fffb7163aff0634ba4128f08be66343 /js/controllers
parent6a49b632e0d7113ca7a6709e0a58097771512f20 (diff)
parentfc13ef1e806116bb7ece5bb06604fa4f5714a6ed (diff)
downloadninja-c97f806fceb2a2e3c668b965e4f8e6fc047a3d9a.tar.gz
Merge branch 'StageDrawingFixes' of https://github.com/mqg734/ninja into v0.7.1
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;