Webkit's blog post from last year on 3D transforms explains the various transform 'functions' that can be used in the -webkit-transform property. For example:
#myDiv {
-webkit-transform: scale(1.1) rotateY(7deg) translateZ(-1px);
}
My question: how do you access individual values in JavaScript? When you read the webkitTransform property of the element, you just get a matrix3d() function with 16 values in it, like this...
matrix3d(0.958684, 0.000000, .....)
Is there a way to just read the value of an individual transform thing, like rotateY()? Or do I have to read it from the matrix3d() string, and how?
Hope this helps! Note that I did not use another library except plain DOM API and native Javascript RegExp function. Hence, this should work universally cross browsers and application.
I ran into this issue this morning. It appears that JavaScript can't read an element's
style.webkitTransform
property until it's been explicitly set in the element'sstyle
attribute (either inline in the HTML or procedurally via JavaScript). As kludgy as this sounds, if you need JS to be able to read CSS transform properties, you might be better off defining their initial values with JavaScript when the DOM is ready.Example, using jQuery:
From this point forward, you'll be able to read the element's transform string and parse through it for the needed values.
This link from Apple Dev Reference might shed more light on the subject:
you can use regex to get a map of property-value:
if variable transformstyle contains the style value
for:
you would get: