简体   繁体   English

生涩的动画-Jquery / CSS3

[英]Jerky animations - Jquery / CSS3

I am trying to combine jQuery and CSS3 to give smooth animations, but I am still finding the animations can be jerky, even on desktop. 我正在尝试将jQuery和CSS3结合使用,以提供流畅的动画,但是我仍然发现即使在台式机上,动画也可能会变得生涩。

I am using the below to move my id from off the side of the page onto the page. 我正在使用以下内容将我的id从页面的一侧移到页面上。

$(id).addClass('active').css({ left: pageWidth })
                        .animate({left: 0}, 500, function(e){deferred.resolve()})
                        .css("-webkit-transform", "translate3d(0px,0px,0px)")
                        .css("-moz-transform", "translate3d(0px,0px,0px)")
                        .css("-ms-transform", "translate3d(0px,0px,0px)")
                        .css("-o-transform", "translate3d(0px,0px,0px)")
                        .css("transform", "translate3d(0px,0px,0px)");

Can anyone give any advice if there is anything further I can do? 如果我还有其他可以做的事情,谁能提供任何建议?

Use a plugin/extension like velocity to automatically use CSS animation for you behind the scenes. 使用诸如Velocity的插件/扩展程序可以在幕后自动为您使用CSS动画。

We recently used it to avoid stuttering of animations on mobile devices and it improved things a lot. 我们最近使用它来避免动画在移动设备上出现卡顿现象,并大大改善了效果。

If you want smoother animations and you can use CSS3 with no restrictions then you can make use of CSS3 Keyframes. 如果您想要更流畅的动画并且可以不受限制地使用CSS3,则可以使用CSS3关键帧。

Take a look at this CSS3 animation collection called Animate.css: 看一下这个名为Animate.css的CSS3动画集合:

http://daneden.github.io/animate.css/ http://daneden.github.io/animate.css/

This makes use of CSS3 Keyframes that runs really smooth. 这利用了运行非常流畅的CSS3关键帧。 You can edit the animations or create new ones depending on what you want to acomplish. 您可以根据要完成的动画来编辑动画或创建新动画。 With Keyframes you can set the state of the animation at any frame of it so you can make it look as smooth as you want depending on how you build it. 使用关键帧,您可以在动画的任何帧上设置动画的状态,以便根据制作方式的不同,使其看起来像想要的那样平滑。

Take a look at this article about Keyframes and if you don't want to use the ones on Animate.css try to modify them or build your own: 看一下有关关键帧的本文,如果您不想使用Animate.css上的关键帧,请尝试修改它们或构建自己的关键帧:

http://css-tricks.com/snippets/css/keyframe-animation-syntax/ http://css-tricks.com/snippets/css/keyframe-animation-syntax/

For the animmation you want to get the code is not that hard. 对于动画,想要获得代码并不难。 You can do this with jQuery animate as well but Keyframes will runs smoother if you work better on the frames. 您也可以使用jQuery动画来执行此操作,但是如果您在框架上工作得更好,则关键帧将运行得更流畅。

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

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