IE Bug: Fading animation makes text render without anti-aliasing
Affects: IE6, IE7
Description
When using jQuery to fade elements, Internet Explorer will remove anti-aliasing from text (causing it to appear pixelated) .
Workaround
Remove the ‘filter’ attribute used by IE to fade elements once the fade is complete (view the full post to read the code)
Code based on GBegen’s comment on Stack Overflow
http://stackoverflow.com/questions/778208/jquery-fadein-leaves-text-not-anti-aliased-in-ie7
(function($) {
$.fn.fadeIn = function(speed, callback) {
return this.animate({opacity: 'show'}, speed, function() {
if ( $.browser.msie )
{
this.style.removeAttribute('filter');
}
if ( $.isFunction(callback) )
{
callback.call(this);
}
});
};
$.fn.fadeOut = function(speed, callback) {
return this.animate({opacity: 'hide'}, speed, function() {
if ( $.browser.msie )
{
this.style.removeAttribute('filter');
}
if ( $.isFunction(callback) )
{
callback.call(this);
}
});
};
$.fn.fadeTo = function(speed, to, callback) {
return this.animate({opacity: to}, speed, function() {
if ( to == 1 && $.browser.msie )
{
this.style.removeAttribute('filter');
}
if ( $.isFunction(callback) )
{
callback.call(this);
}
});
};
})(jQuery);
bookmarked.
awesome.
Great drop in solution. Just a comment, the code has an error: in the fadeTo function, the first condition is supposed to have a couple of ampersands to signify logical AND instead of the escaped html code.
Thanks for this!
Sorry – I missed your comment for a while – thanks for the fix!
[...] Unfortunately this means you have to deal with the IE6/7 text anti-alias bug – workaround here [...]
Smashing. Works a treat. Thanks very much for sharing.
BTW you say “Affects: IE6, IE7″. My client has IE8 and says that it suffers from the same problem.
ยต