Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/417.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用javascript获取元素的rotateY()作为变量_Javascript_Html_Css - Fatal编程技术网

使用javascript获取元素的rotateY()作为变量

使用javascript获取元素的rotateY()作为变量,javascript,html,css,Javascript,Html,Css,对于我网站上的ajax动画,我需要检查元素是否完全转换为 transform: rotateY(-90deg) 我在互联网上找到了这段代码,用于检查元素css值 function getStyle(oElm, strCssRule){ var strValue = ""; if(document.defaultView && document.defaultView.getComputedStyle){ strValue = document.

对于我网站上的ajax动画,我需要检查元素是否完全转换为

transform: rotateY(-90deg)
我在互联网上找到了这段代码,用于检查元素css值

function getStyle(oElm, strCssRule){
    var strValue = "";
    if(document.defaultView && document.defaultView.getComputedStyle){
        strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
    }
    else if(oElm.currentStyle){
        strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
            return p1.toUpperCase();
        });
        strValue = oElm.currentStyle[strCssRule];
    }
    return strValue;
}
用法:

getStyle(document.getElementById('to-transform'), "transform")
这将返回一个matrix3d,它在许多浏览器(如“internet explorer”)中可能不同,在其他版本(如IE7和IE8)中也可能不同:

matrix3d(0.00000000000000006123233995736766, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0.00000000000000006123233995736766, 0, 0, 0, 0, 1) safari
matrix3d(0.00000000000000006123233995736766, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0.00000000000000006123233995736766, 0, 0, 0, 0, 1) chrome
matrix3d(0.00000000000000006123233995736766, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0.00000000000000006123233995736766, 0, 0, 0, 0, 1) opera
matrix3d(0, 0, 1, 0, 0, 1, 0, 0, -1, 0, 0, 0, 0, 0, 0, 1)                                                                   firefox
有没有更简单的方法来检查一个元素是否有旋转90度?因此,代码可以完成动画的最后一部分


注意:它必须是javascript,因为我没有包括jQuery

matrix3d是转换的标准化格式-类似于红色作为颜色转换为rgb255,0,0的方式。获取原始字符串的唯一方法是读取样式表本身,而不是计算的样式。如果我理解你的意思,为了得到rotateY,我必须创建一个函数,将矩阵3d转换为rotateY?