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.
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-transformproperty:Then finally you can
.split()thematrixvalue into something useable:Here is a demo: http://jsfiddle.net/7Yz8B/