How can I achieve smooth resizing or movement of an object over 开发者_如何学运维a period of time. Should I change the position of the object by units smaller than pixels? I am currently timing this using setTimeout, is there a more efficient way of moving an object over a period of time than setTimeout?
How about using jQuery's animate function? It's quite robust.
CSS 3 Animation would probably be faster for browsers that support it, as it's based on native routines.
Other than that... setTimeout
is how you do it. Though setInterval
is probably going to make it easier to make your transitions.
You might take a look at some of the javascript animation libraries and see what specific techniques they use. Or, you could look at stuff like JavaScript Animation From Scratch. Or the animation chapter in John Resig's Secrets of the JavaScript Ninja when he releases it. :)
setTimeout() or setInterval(). You're on the right track.
Yup, setTimeout or setInterval is a good way to go.
There's also a variety of libraries, like jQuery, that have animation features built in, which can make life easier for you.
精彩评论