views:

57

answers:

1

As the title says, how does it work? Looking through the source is a nightmare because it's all using complicated arrays, but I don't really see code which does anything.

Any ideas?

+2  A: 

The animate method works by taking the current value of the property you're animating, and the end value (which you give it) and calculating each "frame" in between. So if your animation is going from 1.0 to 0.0 in 10 steps, it hits .9, .8, .7, etc. It can do this process for any numeric css property.

Essentially it treats the start and end points like the keyframes of the animation and "tweens" the rest of the values it needs to get from one to the other, then runs a loop that processes through each "frame".

Gabriel Hurley
Oh I see, so it's like Flash?Seems kinda hard to implement on it's own?
James Brooks
Have you ever made something like that before?
James Brooks
Have I ever built an animation framework with JS/CSS? I made a really lame one like 6 years ago that moved things around the screen... since then I just use jQuery or Prototype+Scriptaculous. No need to reinvent the wheel. But the concept for basically all computer animation is the same whether it's javascript, flash, 3D animation, whatever.
Gabriel Hurley
Thanks Gabriel!
James Brooks