PhoneGap / Cordova:JQuery动画运行缓慢 [英] PhoneGap/Cordova: JQuery animations running slow

查看:295
本文介绍了PhoneGap / Cordova:JQuery动画运行缓慢的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在PhoneGap / Cordova中构建了一个应用程序,并使用JQuery库来处理像slideUp等一些简单的动画。

I have built a an app in PhoneGap/Cordova and used the JQuery library for some simple animations like slideUp etc.

它们在模拟器上正常工作,尝试在实际的设备上的动画运行真的很矮和慢。

They work fine on the simulator but when I try on an actual device the animations run really chunky and slow.

有办法加速吗?

如果后者是真的,任何人都可以建议一个好的版本让我试试?

If the latter is true can anyone suggest a good version for me to try?

感谢

推荐答案

jQuery动画是使用setInterval对css属性进行动画处理,移动设备上的硬件加速。

jQuery animations are done using a setInterval on the css properties being animated and it is not hardware accelerated on mobile devices.

CSS转换 硬件在大多数现代设备上加速,因此是更好的选择。有一些库可以确保你的jQuery动画使用CSS过渡,而不是昂贵的setInterval动画。

CSS Transitions are hardware accelerated on most modern devices and are therefore a better choice. There are drop in libraries that can make sure your jQuery animations are done using CSS transitions instead of costly setInterval animations.

http://playground.benbarnett.net/jquery-animate-enhanced/

http://ricostacruz.com/jquery.transit/

试试这些。

如果您没有使用 Zepto.js 中缺少的任何功能,请考虑使用它,因为它比jQuery小得多,比移动设备专用的更小和更轻。

If you are not using any of the functionality that is missing from Zepto.js, consider using it instead as it is much smaller and lighter than jQuery and made specifically for mobile devices.

这篇关于PhoneGap / Cordova:JQuery动画运行缓慢的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆