Created
January 27, 2015 19:45
-
-
Save gaearon/a300236df05fb0278c9b to your computer and use it in GitHub Desktop.
getSupportedTransformProperty.js
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
'use strict'; | |
var TRANSFORM_VARIANTS = { | |
'WebkitTransform': '-webkit-transform', | |
'Transform': 'transform' | |
}; | |
function test() { | |
var testEl = document.createElement('div'), | |
style = testEl.style; | |
for (let [jsProp, cssProp] of Object.entries(TRANSFORM_VARIANTS)) { | |
style[jsProp] = `translate3d(0, 0, 0)`; | |
if (style[jsProp].length) { | |
return { | |
js: jsProp, | |
css: cssProp | |
}; | |
} | |
} | |
} | |
var property; | |
function getSupportedTransformProperty() { | |
if (!property) { | |
property = test(); | |
} | |
return property; | |
} | |
module.exports = getSupportedTransformProperty; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment