Skip to content

Instantly share code, notes, and snippets.

@DigiTec
Created November 28, 2012 03:59
Show Gist options
  • Save DigiTec/4158953 to your computer and use it in GitHub Desktop.
Save DigiTec/4158953 to your computer and use it in GitHub Desktop.
Quick and optimized poly-fill for transform that has fallbacks for IE 9 and WebKit based browsers.
(function () {
if (CSSStyleDeclaration.prototype.hasOwnProperty("transform")) {
}
else if (CSSStyleDeclaration.prototype.hasOwnProperty("msTransform")) {
Object.defineProperties(CSSStyleDeclaration.prototype, {
transform: {
get: function get_transform() {
return this.msTransform;
},
set: function set_transform(transform) {
this.msTransform = transform;
}
}
});
}
else {
Object.defineProperties(CSSStyleDeclaration.prototype, {
transform: {
get: function get_transform() {
return this.webkitTransform;
},
set: function set_transform(transform) {
this.webkitTransform = transform;
}
}
});
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment