admin管理员组文章数量:1415421
JSFiddle
I have an example parison of the exact same animation performed by jQuery and another by CSS. The animation is so little, not much happening, so why is jQuery lagging like it is? This is ridiculous.... CSS is animating beautifully though.
Can someone tell me why jQuery animations lag, even when they're as small as this?
JSFiddle
I have an example parison of the exact same animation performed by jQuery and another by CSS. The animation is so little, not much happening, so why is jQuery lagging like it is? This is ridiculous.... CSS is animating beautifully though.
Can someone tell me why jQuery animations lag, even when they're as small as this?
Share Improve this question edited Aug 2, 2011 at 18:04 Sparky 98.8k26 gold badges202 silver badges290 bronze badges asked Apr 10, 2011 at 15:59 android.nickandroid.nick 11.2k24 gold badges79 silver badges112 bronze badges 4- I guess it's because jquery has to modify the padding of the DOM element using timers and a loop. The CSS is part of the browser engine – JohnP Commented Apr 10, 2011 at 16:03
-
Also, there is no point in adding
'backgroundColor': 'rgb(229, 243, 250)'
in your animate call. That doesn't get animated – JohnP Commented Apr 10, 2011 at 16:04 - if you are referring specifically to Safari's CSS transitions, then one reason is that they are hardware optimized for iOS (and OSX) devices. – DA. Commented Apr 11, 2011 at 4:42
- I'm referring to webkit, firefox and opera browsers. Safari is as optimized for osx devices as chrome is. They both run webkit, chrome is just done better. – android.nick Commented May 4, 2011 at 6:20
2 Answers
Reset to default 4You must remove the CSS transition rules on the div animated by jQuery, in this example:
http://jsfiddle/mT39H/
Both behave the same.
The reason is that jQuery animates by changing the position x times per second, but then the browser tries to animate between these values.
I'd say it has to do with the ratio of paddingBottom to the animation time. Try changing animation time to a smaller value and you'll see it's a lot smoother.
(set to 75ms - link)
本文标签: javascriptAnimation jQuery VS CSS jQuery lagswhyjsFiddle comparisonexampleStack Overflow
版权声明:本文标题:javascript - Animation: jQuery VS CSS: jQuery lags, why? - jsFiddle comparisonexample - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745203484a2647513.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论