SpringAnimation
public struct SpringAnimation<Value: VectorConvertible>: ValueAnimationType
The SpringAnimation
struct is an implementation of
ValueAnimationType
that uses a configurable spring function to animate
the value.
Spring animations do not have a duration. Instead, you should configure the properties in ‘configuration’ to customize the way the spring will change the value as the simulation advances. The animation is finished when the spring has come to rest at its target value.
SpringAnimation instances use a DynamicSolver
containing a
SpringFunction
internally to perform the spring calculations.
-
Creates a new
SpringAnimation
instance.Declaration
Swift
public init(from: Value, target: Value, velocity: Value = Value.zero)
Parameters
from
The value of the animation at time
0
.target
The final value that the spring will settle on at the end of the animation.
velocity
The initial velocity at the start of the animation.
-
Advances the animation.
Declaration
Swift
public mutating func advance(_ elapsed: Double)
Parameters
elapsed
The time (in seconds) to advance the animation.
-
Returns
true
if the spring has reached a settled state.Declaration
Swift
public var finished: Bool
-
The current value.
Declaration
Swift
public var value: Value
-
The current velocity.
Declaration
Swift
public var velocity: Value
-
The value that the spring will move toward.
Declaration
Swift
public var target: Value
-
The configuration of the underlying spring simulation.
Declaration
Swift
public var configuration: SpringConfiguration