开发者

why is animate so laggy in ie8 and below?

hi I have used jQuery animate to animate the padding on my menu items. It is very simple code as follows:

$('.menu li a').hover(function(){
    $(this).animate({
     开发者_高级运维   paddingLeft:'18px',
        paddingRight:'18px'
    }, 350);
}, function(){
    $(this).animate({
        paddingLeft:'5px',
        paddingRight:'5px'
    }, 350);
});

But for some reason in IE8 and 7 it is really really laggy. Anyone got any ideas. A lot of the javascript is laggy for that matter but I don't know why. The website is http://www.rnmtest.co.uk/rnm


It seems that animation is laggy with FF7 too (when you hover in/out a lot). Might be that some of your script somewhere is doing infinite loop or something like that. Review your code. Also test without any js libraries except jQuery and animation script.


You asked:

why is animate so laggy in ie8 and below?

The direct answer to your question is: Because IE7/8's Javascript engine is rubbish.


Hover is expensive. Hover fires an event every time your mouse is above the element. Mouseenter (and mouseout afterwards) is cheaper for what you are doing and fires it's event only once.

That is especially true with slow JS engines.

The mouseenter event is provided by jquery in newer versions i think.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜