Last active
November 16, 2020 11:12
-
-
Save svassr/9f2113c74c29ec49b14fb08df6a2229a to your computer and use it in GitHub Desktop.
getVendorPrefix to apply in javascript
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
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