aboutsummaryrefslogtreecommitdiff
path: root/js/controllers/styles-controller.js
diff options
context:
space:
mode:
authorJon Reid2012-04-10 14:52:23 -0700
committerJon Reid2012-04-10 14:52:23 -0700
commitc19987997758cf47ac9b93a2a767a0e2a9072745 (patch)
treeeb68491c5d04a5cf5ab75bedf2d6bbed3c7a3603 /js/controllers/styles-controller.js
parent03a3b32b9b0fd2dc8e4b54bfd5282fd1f8fb6ed6 (diff)
parent422b14fc60be84c116115f2e71e3499e232f3f05 (diff)
downloadninja-c19987997758cf47ac9b93a2a767a0e2a9072745.tar.gz
Merge remote-tracking branch 'ninja-jduran/TimelineUber' into timeline-local
Diffstat (limited to 'js/controllers/styles-controller.js')
-rwxr-xr-xjs/controllers/styles-controller.js66
1 files changed, 65 insertions, 1 deletions
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index addfc24e..5d5f27ba 100755
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -836,7 +836,7 @@ var stylesController = exports.StylesController = Montage.create(Component, {
836 ///// For a given CSSKeyframesRule, we may add styles to the keyframe at 836 ///// For a given CSSKeyframesRule, we may add styles to the keyframe at
837 ///// given index. 837 ///// given index.
838 838
839 setKeyframeStyle : { 839 setKeyframeStyles : {
840 value : function(rule, keyframeIndex, property, value, useImportant) { 840 value : function(rule, keyframeIndex, property, value, useImportant) {
841 return this.setStyles(rule.cssRules[keyframeIndex], property, value, useImportant); 841 return this.setStyles(rule.cssRules[keyframeIndex], property, value, useImportant);
842 } 842 }
@@ -1124,6 +1124,70 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1124 } 1124 }
1125 }, 1125 },
1126 1126
1127 ///// Get Matrix From Element
1128 ///// Returns the matrix from an element's -webkit-transform
1129 //// TODO - This routine should eventually check for other transform styles, i.e., rotateX, translateZ, etc.
1130
1131 getMatrixFromElement : {
1132 value: function(element, isStage) {
1133 var xformStr = this.getElementStyle(element, "-webkit-transform", false, isStage),
1134 mat;
1135
1136 if (xformStr) {
1137 var index1 = xformStr.indexOf( "matrix3d(");
1138 if (index1 >= 0) {
1139 index1 += 9; // do not include 'matrix3d('
1140 var index2 = xformStr.indexOf( ")", index1 );
1141 if (index2 >= 0) {
1142 var substr = xformStr.substr( index1, (index2-index1));
1143 if (substr && (substr.length > 0)) {
1144 var numArray = substr.split(',');
1145 var nNums = numArray.length;
1146 if (nNums == 16) {
1147 // gl-matrix wants row order
1148 mat = numArray;
1149 for (var i=0; i<16; i++) {
1150 mat[i] = Number( mat[i] );
1151 }
1152 }
1153 }
1154 }
1155 }
1156 }
1157 return mat;
1158 }
1159 },
1160
1161 ///// Get Perspective Distance From Element
1162 ///// Returns the perspective from an element's -webkit-transform
1163
1164 getPerspectiveDistFromElement : {
1165 value: function(element, isStage) {
1166 var xformStr = this.getElementStyle(element, "-webkit-transform", false, isStage),
1167 dist;
1168
1169 if (xformStr) {
1170 var index1 = xformStr.indexOf( "perspective(");
1171 if (index1 >= 0) {
1172 index1 += 12; // do not include 'perspective('
1173 var index2 = xformStr.indexOf( ")", index1 );
1174 if (index2 >= 0) {
1175 var substr = xformStr.substr( index1, (index2-index1));
1176 if (substr && (substr.length > 0)) {
1177 dist = parseInt( substr );
1178 }
1179 }
1180 }
1181 } else {
1182 xformStr = this.getElementStyle(element, "-webkit-perspective", false, isStage);
1183 if(xformStr) {
1184 dist = parseInt(xformStr);
1185 }
1186 }
1187 return dist;
1188 }
1189 },
1190
1127 ///// Create Rule From Inline Style 1191 ///// Create Rule From Inline Style
1128 ///// Creates a rule for an inline style with a specified, or partially random selector. 1192 ///// Creates a rule for an inline style with a specified, or partially random selector.
1129 1193