Last active
December 23, 2015 02:59
-
-
Save JimBobSquarePants/6570156 to your computer and use it in GitHub Desktop.
Gets the correct vendor property name for the current browser. ("transition" => "MozTransition")
This file contains 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
getVendorPropertyName = function (prop) { | |
/// <summary>Gets the correct vendor property name for the current browser.</summary> | |
/// <param name="prop" type="String">The property to return the name for.</param> | |
/// <returns type="String">The correct vendor property name.</returns> | |
var el = document.createElement("div"); | |
if (prop in el.style) { | |
return prop; | |
} | |
var prefixes = ["Moz", "Webkit", "O", "ms"], | |
suffix = prop.charAt(0).toUpperCase() + prop.substr(1), | |
i, | |
length = prefixes.length; | |
for (i = 0; i < length; i += 1) { | |
var vendorProp = prefixes[i] + suffix; | |
if (vendorProp in el.style) { | |
return vendorProp; | |
} | |
} | |
return false; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment