Created
September 7, 2016 15:32
-
-
Save josephdburdick/13d9895b6855644c2a6a06ad5e9910a6 to your computer and use it in GitHub Desktop.
Cross-browser transform translate3d in Javascript
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function getSupportedPropertyName(properties) { | |
for (var i = 0; i < properties.length; i++) { | |
if (typeof document.body.style[properties[i]] != "undefined") { | |
return properties[i]; | |
} | |
} | |
return null; | |
} | |
var transform = ["transform", "msTransform", "webkitTransform", "mozTransform", "oTransform"]; | |
var item = document.querySelector("#theItem"); | |
var transformProperty = getSupportedPropertyName(transform); | |
if (transformProperty) { | |
item.style[transformProperty] = translate3d(someValueX, someValueY, 0px); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment