Skip to content

Instantly share code, notes, and snippets.

@JimBobSquarePants
Last active December 23, 2015 02:59
Show Gist options
  • Save JimBobSquarePants/6570156 to your computer and use it in GitHub Desktop.
Save JimBobSquarePants/6570156 to your computer and use it in GitHub Desktop.
Gets the correct vendor property name for the current browser. ("transition" => "MozTransition")
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