jquery css 和 animate 函数效率

标签 jquery css performance jquery-animate

所以我想知道你们对使用 jquery css 或 animate 属性对对象进行动画处理的效率有何看法。例如..

$('button').click(function(){
     $('obj to change').css( 'pos', x );
});

这与 css 转换属性一起使用

CSS:

transition:all 0.7s ease-in-out; 

VS

$('button').click(function(){
     $('obj to change').animate({ pos , 'x' });
}, 2000, function() { 
     // Animation complete.
});

提前感谢大家的意见,或者如果您有更好的建议。

最佳答案

CSS3 转换是硬件加速的,因此您可以在支持的浏览器中看到性能的巨大提升。我强烈建议使用 http://ricostacruz.com/jquery.transit/ - 它检测浏览器是否支持 css3 转换,并在旧版浏览器上回退到常规 .animate()。

关于jquery css 和 animate 函数效率,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16193554/

相关文章:

c - 在未排序的数组中找到差值为输入值 'k' 的一对数字

html - DIV 与 UL、LI 性能

sql - Oracle中分页查询的速度

javascript - 默认为文件夹中的任何 html 文件

html - Bootstrap 将 div 内容推送到新行

jquery - 从驻留在 <a> 标记内的图像中获取 "alt"属性

javascript - php 按字母顺序分页

单击时的 Javascript 不适用于 setInterval

jquery - 获取不同容器内相同元素类的jquery索引

html - 在与 HTML 表格相同的行上显示文本?