[][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.


Pager is similar to Scroll, except it contains user supplied snap points which the simulation will be attracted to. These snap points are supplied to the constructor.


A SnapPoint is either an end point or a point of attraction. Every pager needs at least two snap points to define the extents


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.



Any number can be either between two snap points, or beyond one of the extents.



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