If this was set using a matrix, I think you cannot with a simple way, but you can easily analyze the value:
var matrixRegex = /matrix\((-?\d*\.?\d+),\s*0,\s*0,\s*(-?\d*\.?\d+),\s*0,\s*0\)/, matches = $(element).css('-webkit-transform').match(matrixRegex);
matches[1] will contain scaleX, and matches[2] will contain scaleY. If it is possible that other transformations have also been applied, you need to fine-tune the regex, because now it assumes that all other parameters are 0.
One way to get scale values ββcan be to remove any transformations, measure the calculated width / height of the element, then add them back and measure again. Then separate the new / old values. Not tried, but it might work. JQuery itself uses a similar approach for many dimensions; it even has the undocumented function $.swap() just for that.
PS: You use -o-transform -moz-transform and -ms-transform too, right?
Lea Verou Apr 09 '11 at 9:40 2011-04-09 09:40
source share