[][src]Crate gravitas

Gravitas is a collection of equations for making UI elements move in response to touch gestures.

There are also implementations for Java and JavaScript (which has some interactive examples).

Each simulation models a single value and generally has a setup function that takes the initial position and velocity. Normally you would compute these in response to a touch gesture ending. All of the simulations are parametric over time and have been algebraically integrated (rather than using a numerical integration method at runtime). The advantage of algebraic integration is lower CPU overhead, and no odd behavior if frames are dropped.



a position with velocity that slows down due to drag.


a position under the influence of gravity (or any other constant acceleration), as defined by Newton's 2nd Law: F = ma.


a combination of friction and springs to create a touch-driven scrolling simulation.


a position controlled by a spring as defined by Hooke's law, F = -kx * cv.



common methods implemented by every simulation allowing easy integration into an animation system.