Skip to content

Instantly share code, notes, and snippets.

@gaearon
Created January 27, 2015 19:45
Show Gist options
  • Save gaearon/a300236df05fb0278c9b to your computer and use it in GitHub Desktop.
Save gaearon/a300236df05fb0278c9b to your computer and use it in GitHub Desktop.
getSupportedTransformProperty.js
'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