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.js66
1 files changed, 65 insertions, 1 deletions
diff --git a/js/controllers/styles-controller.js b/js/controllers/styles-controller.js
index d36c8cb9..3e56f25c 100755
--- a/js/controllers/styles-controller.js
+++ b/js/controllers/styles-controller.js
@@ -844,7 +844,7 @@ var stylesController = exports.StylesController = Montage.create(Component, {
844 ///// For a given CSSKeyframesRule, we may add styles to the keyframe at 844 ///// For a given CSSKeyframesRule, we may add styles to the keyframe at
845 ///// given index. 845 ///// given index.
846 846
847 setKeyframeStyle : { 847 setKeyframeStyles : {
848 value : function(rule, keyframeIndex, property, value, useImportant) { 848 value : function(rule, keyframeIndex, property, value, useImportant) {
849 return this.setStyles(rule.cssRules[keyframeIndex], property, value, useImportant); 849 return this.setStyles(rule.cssRules[keyframeIndex], property, value, useImportant);
850 } 850 }
@@ -1132,6 +1132,70 @@ var stylesController = exports.StylesController = Montage.create(Component, {
1132 } 1132 }
1133 }, 1133 },
1134 1134
1135 ///// Get Matrix From Element
1136 ///// Returns the matrix from an element's -webkit-transform
1137 //// TODO - This routine should eventually check for other transform styles, i.e., rotateX, translateZ, etc.
1138
1139 getMatrixFromElement : {
1140 value: function(element, isStage) {
1141 var xformStr = this.getElementStyle(element, "-webkit-transform", false, isStage),
1142 mat;
1143
1144 if (xformStr) {
1145 var index1 = xformStr.indexOf( "matrix3d(");
1146 if (index1 >= 0) {
1147 index1 += 9; // do not include 'matrix3d('
1148 var index2 = xformStr.indexOf( ")", index1 );
1149 if (index2 >= 0) {
1150 var substr = xformStr.substr( index1, (index2-index1));
1151 if (substr && (substr.length > 0)) {
1152 var numArray = substr.split(',');
1153 var nNums = numArray.length;
1154 if (nNums == 16) {
1155 // gl-matrix wants row order
1156 mat = numArray;
1157 for (var i=0; i<16; i++) {
1158 mat[i] = Number( mat[i] );
1159 }
1160 }
1161 }
1162 }
1163 }
1164 }
1165 return mat;
1166 }
1167 },
1168
1169 ///// Get Perspective Distance From Element
1170 ///// Returns the perspective from an element's -webkit-transform
1171
1172 getPerspectiveDistFromElement : {
1173 value: function(element, isStage) {
1174 var xformStr = this.getElementStyle(element, "-webkit-transform", false, isStage),
1175 dist;
1176
1177 if (xformStr) {
1178 var index1 = xformStr.indexOf( "perspective(");
1179 if (index1 >= 0) {
1180 index1 += 12; // do not include 'perspective('
1181 var index2 = xformStr.indexOf( ")", index1 );
1182 if (index2 >= 0) {
1183 var substr = xformStr.substr( index1, (index2-index1));
1184 if (substr && (substr.length > 0)) {
1185 dist = parseInt( substr );
1186 }
1187 }
1188 }
1189 } else {
1190 xformStr = this.getElementStyle(element, "-webkit-perspective", false, isStage);
1191 if(xformStr) {
1192 dist = parseInt(xformStr);
1193 }
1194 }
1195 return dist;
1196 }
1197 },
1198
1135 ///// Create Rule From Inline Style 1199 ///// Create Rule From Inline Style
1136 ///// Creates a rule for an inline style with a specified, or partially random selector. 1200 ///// Creates a rule for an inline style with a specified, or partially random selector.
1137 1201