简体   繁体   English

为什么[my] CSS3 / jQuery转换得如此不完美,如何使它们更加流畅?

[英]Why are [my] CSS3/jQuery transitions so imperfectly smooth, and how do I make them more smooth?

As much as I've searched for information about this all over the internet, I can't find anything about it, so I've come here for help. 尽管我在互联网上搜索了有关这方面的信息,但我找不到任何相关信息,所以我来这里寻求帮助。

What's been bugging me: That no matter which method I use -- a jQuery .animate, or a css3 transition, [my] animations don't appear to be perfectly smooth. 什么一直困扰着我:无论我使用哪种方法 - jQuery .animate,或css3过渡,[my]动画似乎都不是非常流畅。 I didn't understand why they appear this way at first, and it's so subtle I ended up having to do some video capping to prove it. 我不明白为什么他们一开始就这样出现,而且它是如此微妙,我最终不得不做一些视频封顶来证明这一点。 But it's definitely there -- the animations are juttery. 但它肯定存在 - 动画是juttery。 Sometimes a frame happens too fast, and sometimes too slow. 有时框架发生得太快,有时太慢。

Flip it back and forth six or seven times, and you'll hopefully see what I'm talking about. 来回翻转六到七次,你会希望看到我在说什么。

I can understand this with jQuery -- JS execution isn't perfect. 我可以用jQuery理解这一点 - JS执行并不完美。 A quick profiling shows that indeed, when using jQuery anim, some frames get triggered too soon and some frames are late. 一个快速的分析表明,当使用jQuery动画时,某些帧会很快被触发而某些帧会延迟。 But with CSS3? 但是使用CSS3?

What do people do to solve this problem? 人们做了什么来解决这个问题?

在代码之前设置这个JS:

jQuery.fx.interval = 100;

I am moving the container using the margin-left CSS property and .animate of jQuery and is pretty smooth. 我使用margin-left CSS属性和jQuery的.animate移动容器,非常流畅。 Use the arrow keys to use it (left and right) 使用箭头键使用它(左和右)

The current version of that project its now full of images, text, iframes and is still smooth. 该项目的当前版本现在充满了图像,文本,iframe并且仍然很流畅。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM