StopLogic
class StopLogic : MotionInterpolator
| kotlin.Any | ||
| ↳ | androidx.constraintlayout.motion.widget.MotionInterpolator | |
| ↳ | androidx.constraintlayout.motion.utils.StopLogic |
This contains the class to provide the logic for an animation to come to a stop. The setup defines a series of velocity gradients that gets to the desired position ending at 0 velocity. The path is computed such that the velocities are continuous
Summary
Public constructors |
|---|
Public functions |
|
|---|---|
Unit |
config(Configure the stop logic base on the parameters |
String! |
Debugging logic to log the state. |
Float |
Gets the interpolated given the original interpolation |
Float |
Gets the velocity at the last interpolated point |
Float |
getVelocity(x: Float)Get the velocity at a point in time |
Boolean |
|
Unit |
springConfig(This configure the stop logic to be a spring. |
Inherited functions |
||
|---|---|---|
|
Public constructors
Public functions
config
fun config(
currentPos: Float,
destination: Float,
currentVelocity: Float,
maxTime: Float,
maxAcceleration: Float,
maxVelocity: Float
): Unit
Configure the stop logic base on the parameters
debug
fun debug(desc: String!, time: Float): String!
Debugging logic to log the state.
| Returns | |
|---|---|
String! |
string useful for debugging the state of the StopLogic |
getInterpolation
fun getInterpolation(v: Float): Float
Gets the interpolated given the original interpolation
| Parameters | |
|---|---|
v: Float |
| Returns | |
|---|---|
Float |
getVelocity
fun getVelocity(): Float
Gets the velocity at the last interpolated point
| Returns | |
|---|---|
Float |
getVelocity
fun getVelocity(x: Float): Float
Get the velocity at a point in time
| Parameters | |
|---|---|
x: Float |
| Returns | |
|---|---|
Float |
springConfig
fun springConfig(
currentPos: Float,
destination: Float,
currentVelocity: Float,
mass: Float,
stiffness: Float,
damping: Float,
stopThreshold: Float,
boundaryMode: Int
): Unit
This configure the stop logic to be a spring. Moving from currentPosition(P0) to destination with an initial velocity of currentVelocity (V0) moving as if it has a mass (m) with spring constant stiffness(k), and friction(c) It moves with the equation acceleration a = (-k.x-c.v)/m. x = current position - destination v is velocity
| Parameters | |
|---|---|
currentPos: Float |
The current position |
destination: Float |
The destination position |
currentVelocity: Float |
the initial velocity |
mass: Float |
the mass |
stiffness: Float |
the stiffness or spring constant (the force by which the spring pulls) |
damping: Float |
the stiffness or spring constant. (the resistance to the motion) |
stopThreshold: Float |
(When the max velocity of the movement is below this it stops) |
boundaryMode: Int |
This controls if it overshoots or bounces when it hits 0 and 1 |