Reputation: 5243
i am making this global function which will simply change an element's transform property. This is what i have.
function transform(element, value) {
if(element.style.webkitTransform) element.style.webkitTransform = value;
else if(element.style.MozTransform) element.style.MozTransform = value;
}
I also want to add opera and ie to the above function. i have opera running with me so i can test opera but i dont have ie 9. Also i cant figure out how can i access opera's either. Can anyone please help?
I want something like this
function transform(element, value) {
if(element.style.webkitTransform) element.style.webkitTransform = value;
else if(element.style.MozTransform) element.style.MozTransform = value;
else if(element.style.msTransform) element.style.msTransform = value;
else if(element.style.oTransform) element.style.oTransform = value;
}
Upvotes: 3
Views: 2418
Reputation: 401
With older versions of Opera, based on Presto engine, you should do forced precision to reduce the side effects of the 'early' implementation of CSS 2D transforms, such as:
var action = "scale(" + value.toPrecision(4) + ")";
element.style.transform = action;
element.style.oTransform = action;
I don't believe this has negative impact on modern implementations.
Upvotes: 0
Reputation: 1988
You can always just set them all. The other browsers will ignore styles they cannot understand.
function transform(element, value) {
element.style.webkitTransform = value;
element.style.MozTransform = value;
element.style.msTransform = value;
element.style.OTransform = value;
}
Upvotes: 9