/** * Construct a mutation observer. * See https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver *//** * var target = document.querySelector('#id'); */vartarget=document.querySelector('#id');/** * create an observer instance */varobserver=newMutationObserver(function(mutations){/** * We could iterate the mutations here, * but I don't really care it now. */varst=window.getComputedStyle(target,null);vartr=st.getPropertyValue("-webkit-transform")||st.getPropertyValue("-moz-transform")||st.getPropertyValue("-ms-transform")||st.getPropertyValue("-o-transform")||st.getPropertyValue("transform");console.log('Matrix: '+tr);// rotation matrix - http://en.wikipedia.org/wiki/Rotation_matrixvarvalues=tr.split('(')[1];values=values.split(')')[0];values=values.split(',');vara=values[0];varb=values[1];varc=values[2];vard=values[3];varscale=Math.sqrt(a*a+b*b);// arc sin, convert from radians to degrees, round// DO NOT USE: see update belowvarsin=b/scale;varangle=Math.round(Math.asin(sin)*(180/Math.PI));// works!console.log('Scale: '+scale+';Rotate: '+angle+'deg');});/** * Configuration of mutation observer. */varconfig={attributes:true,childList:true,characterData:true};/** * pass in the target node, as well as the observer options */observer.observe(target,config);