Reputation: 14008
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
Upvotes: 0
Views: 70
Reputation: 1042
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.
Upvotes: 0
Reputation: 168655
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.
Upvotes: 1
Reputation: 1412
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.
Upvotes: 1