I am currently using JQuery to perform a single task: animatio开发者_C百科n of width on a div. I really hate to be loading in the entire JQuery library for this single task and was wondering if anyone knew how to do a standalone function like:
div.animate('56');
Where 56 is the percentage of the width I'd like the div to animate to. If anyone has any advice or ideas, I'd really appreciate it!
Ben
To be honest, at 55kb (or 19kb if your server supports gzip), I'd just go with jQuery.
However, this page looks like it has some scripts and info to help you do what you want:
http://www.hesido.com/web.php?page=javascriptanimation
And the source is here:
http://www.hesido.com/web/animfunctions.js
Certainly possible, but it's generally a pain to get animations working properly across the standard array of browsers.
If jQuery/jQuery UI is overkill for what you're doing, you may want to give smaller libraries like MooTools and moo.fx a try. Also take note that Google offers a javascript API to include libraries that are likely to already be cached on a user's browser.
精彩评论