jQuery - .css('transform') 在 Internet Explorer 中返回的值与 Chrome/Firefox 不同

jQuery - .css('transform') returning different values in Internet Explorer than Chrome/Firefox

作为背景知识,我正在使用 Greensock 的 Draggable 通过 transform:translate3d 属性.

在 y 轴上移动对象

但是,当我使用 .css('transform') 在移动对象上调用 return 时,在 IE 中编辑的 return 值与 Chrome/Firefox 不同 returning.

例如,Chrome/Firefox return matrix(1, 0, 0, 1, 0, 5) 而 IE returns matrix3d(1, 0, 0, 0, 0, 1, 0, 0, 0, 0, 1, 0, 0, 5, 0, 1).

我需要解析并获取不断变化的 y 值,即 Chrome/Firefox 中的位置 [5] 和 IE 中的位置 [13]。如果不实施一些浏览器嗅探,这显然被证明是一个问题。

有没有办法让我标准化 returned 的 属性 值(到 matrix 或 matrix3d),或者在不同的地方自己获取 y 值方式?

编辑: 不知道为什么我的问题得到了负面评价;如果我没有提供足够的信息,请告诉我。

从微软找到这个,https://msdn.microsoft.com/en-us/library/jj200269(v=vs.85).aspx

All other transformation functions are based on the matrix3d function.

您可以提取您需要的值。看来这是唯一的选择了。

万一其他人遇到这个问题并且正在使用 Greensock (GSAP),我在 Greensock forums:

得到了以下答案

If you're trying to figure out the y position of the Draggable's target, did you know that the Draggable instance has a "y" property as well? So you could just tap into that.

Example:

Draggable.create("#id", {
    onDrag:function() {
        console.log(this.y);
    }
});

另一个答案表明,不同的值可能是 jQuery 的 .css('transform').

中的错误造成的

不管怎样,这解决了我的问题。