by doomlaser · 12y ago · 0 comments
These interpolation curves can be nice in a pinch, but like I said before, the curves the curves are static, and so you can run into problems if you want to interrupt an action with another, or layer multiple tweens together.
One particularly effective way to get natural eased motion is to use a function that outputs something like the movement of a simple damped harmonic spring. With a system like this, you specify a target position relative to the current position, the sponginess of the spring, and the speed of which it oscillates. This can give you very natural results and feels a lot closer to a real physical system than a lot of these interpolation curves (EaseInOutExp, etc).
Here's some code for a damped spring system that can work really well as an alternative to predefined tween curves in user interfaces and games: http://www.ryanjuckett.com/programming/damped-springs/
And for more non-Penner interpolation alternatives, check out: http://sol.gfxile.net/interpolation/
I think the main advantage of using physical models is that you can feed velocity (from a touch gesture) into them. You can't really do that with the Penner equations (you could compute duration based on the derivative at t=0, but it won't feel very nice).
I wrote up some of the advantages of using physical models for UI animations and interactions here: http://iamralpht.github.io/physics/