使用 jQuery 检测跨浏览器的 CSS 转换变化
我需要使用 jQuery 检测 CSS 变换属性是否已更改。在 firebug 中,我希望检测更改的 CSS 属性呈现如下:
-moz-transform:translate(-0px, 0px)
我需要检测这是否已更改为另一个像素属性。例如:
-moz-transform:translate(-100px, 0px)
更多详细信息:
最终,我尝试在以下演示中检测单击和拖动之间的情况。
http://cubiq.org/dropbox/iscroll4/examples/carousel/
我想我可以在当前的变换属性上查询mouseup,如果它保持不变,则为单击,或者如果变换属性发生更改,则为拖动。
I need to detect if the CSS transform property has changed using jQuery. In firebug the CSS property i'm looking to detect changes on is rendered like this:
-moz-transform: translate(-0px, 0px)
I need to detect whether this has changed to another pixel property. For example:
-moz-transform: translate(-100px, 0px)
More details:
Ultimately I'm trying to detect between a click and a drag on the following demo.
http://cubiq.org/dropbox/iscroll4/examples/carousel/
I figured that I could query mouseup
on the current transform property and if it remained the same that it was a click or if the transform property changed it would be a drag.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用 Modernizr 创建供应商前缀,然后可以使用
.split()
分解.css()
的输出并获取所需的值。以下是获取正确前缀属性的方法:
来源:http://www.modernizr。 com/docs/#prefixed
然后你可以使用
.css()
来获取-vender-transform
属性:最后你可以 <代码>.split()
matrix
值转换为可用的东西:这是一个演示:http://jsfiddle.net/7Yz8B/
You can use Modernizr to create the vender prefix and then you can use
.split()
to break apart the output from.css()
and get the desired values.Here is a method of getting the properly prefixed property:
Source: http://www.modernizr.com/docs/#prefixed
Then you can use
.css()
to get the-vender-transform
property:Then finally you can
.split()
thematrix
value into something useable:Here is a demo: http://jsfiddle.net/7Yz8B/