Skip to content

Instantly share code, notes, and snippets.

@svassr
Last active November 16, 2020 11:12
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save svassr/9f2113c74c29ec49b14fb08df6a2229a to your computer and use it in GitHub Desktop.
Save svassr/9f2113c74c29ec49b14fb08df6a2229a to your computer and use it in GitHub Desktop.
getVendorPrefix to apply in javascript
export function getTransformPrefix(){
return GetVendorPrefix(["transform", "msTransform", "MozTransform", "WebkitTransform", "OTransform"]);
}
export function getTransitionPrefix(){
return GetVendorPrefix(["transition", "msTransition", "MozTransition", "WebkitTransition", "OTransition"]);
}
export function getAnimationPrefix(){
return GetVendorPrefix(["animation", "msAnimation", "MozAnimation", "WebkitAnimation", "OAnimation"]);
}
export function createStyleObj(prop, value){
var style = {};
if(prop){
style[prop] = value;
console.log('GetVendorPrefix createStyleObj:',style);
}
return style;
}
export default function GetVendorPrefix(arrayOfPrefixes) {
var tmp = document.createElement("div");
var result = null;
for (var i = 0; i < arrayOfPrefixes.length; ++i) {
if (typeof tmp.style[arrayOfPrefixes[i]] != 'undefined') {
result = arrayOfPrefixes[i];
}
}
console.log('GetVendorPrefix result:', result);
return result;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment