Created
September 17, 2014 17:05
-
-
Save webcyou/56fa6a63c845a6f516cc to your computer and use it in GitHub Desktop.
get transform val
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var div = document.getElementById("result"), | |
elm = document.getElementById("elm"); | |
var computedStyle,mat,a,b,c,d,e,f, | |
reMat = /matrix\(\s*(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)\s*\,\s*(-?\d+(?:\.\d+)?)\s*,\s*(-?\d+(?:\.\d+)?)\s*\)/; | |
computedStyle = window.getComputedStyle(elm, null); | |
mat = computedStyle['-webkit-transform'].match(reMat).slice(1); | |
a = parseFloat(mat[0], 10); | |
b = parseFloat(mat[1], 10); | |
c = parseFloat(mat[2], 10); | |
d = parseFloat(mat[3], 10); | |
e = parseFloat(mat[4], 10); | |
f = parseFloat(mat[5], 10); | |
div.innerHTML = "mat:" + mat + "<br>" + "a:" + a + "<br>" + "b:" + b + "<br>" + "c:" + c + "<br>" + "d:" + d + "<br>" + "e:" + e + "<br>" + "f:" + f + "<br>"; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment