admin管理员组文章数量:1426027
I'm looking for a way to use css animations, but if the users browser doesn't do css animations - to then fall back to use Jquery for the animation. Is there an easy way to do this in Jquery? a plugin would be OKAY, if it were a small plugin, but i'm really looking for some way of doing this in jquery if possible. The only reason I want to use css animations is because of the much lower Processor power used when using css animations.
I'm looking for a way to use css animations, but if the users browser doesn't do css animations - to then fall back to use Jquery for the animation. Is there an easy way to do this in Jquery? a plugin would be OKAY, if it were a small plugin, but i'm really looking for some way of doing this in jquery if possible. The only reason I want to use css animations is because of the much lower Processor power used when using css animations.
Share Improve this question edited Jul 28, 2012 at 18:51 Rich Bradshaw 73.1k46 gold badges188 silver badges241 bronze badges asked Apr 10, 2011 at 14:19 android.nickandroid.nick 11.2k24 gold badges79 silver badges112 bronze badges 1- 2 Don't forget the fallback's fallback (if JavaScript is disabled) :P – Shaz Commented Apr 10, 2011 at 14:29
3 Answers
Reset to default 5The jQuery animate enhanced plugin uses CSS transitions without having to write specific code for transition capable browsers
The alternative is not very encouraging: you could add a feature detection library such as Modernizr and then write specific code for every case, such as...
if (Modernizr.csstransitions) {
$("#yourdiv").css({
"-webkit-transform" : "translate(0, 10)",
"-o-transform" : "translate(0, 10)",
"-moz-transform" : "translate(0, 10)",
"-ms-transform" : "translate(0, 10)",
"transform" : "translate(0, 10)"
});
}
else {
//do jquery animate stuff
}
You should not care about it. Animations are not vital. If you do progressive enhancement, every user will get the best experience their browser lets them to have :).
If you care about that "processor power" so much, you do not want to have animations on IE at all. Otherwise, use just jQuery, that seems to be best for your particular needs.
jQuery remends to use jQuery.support to make sure that some functionality in maintained by browser. Like:
jQuery.support.opacity //returns true/false
Core jQuery doesn't give way to test CSS3 properties, but plugins do. You can find some of such plugins in the ments after function description (like this one )
本文标签:
版权声明:本文标题:javascript - When using CSS transitionsanimationsetc., what's the best way to fall back to jquery if the users browser d 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745415794a2657678.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论