Spring
public final class Spring<Value> where Value : VectorConvertible
Animates values using a spring function.
let spring = Spring(value: CGPoint.zero)
spring.target = CGPoint(x: 300, y: 200)
-
Initializes a new spring converged at the given value, using default configuration options for the spring function.
Declaration
Swift
public init(initialValue: Value)
-
Invoked every time the spring updates.
Declaration
Swift
public var onChange: ((Value) -> Void)? { get set }
-
The current value of the spring.
Declaration
Swift
public var value: Value { get set }
-
The current velocity of the spring.
Declaration
Swift
public var velocity: Value { get set }
-
The spring’s target.
Declaration
Swift
public var target: Value { get set }
-
Removes any current velocity and snaps the spring directly to the given value.
Declaration
Swift
public func reset(to value: Value)
Parameters
value
The new value that the spring will be reset to.
-
How strongly the spring will pull the value toward the target,
Declaration
Swift
public var tension: Double { get set }
-
The resistance that the spring encounters while moving the value.
Declaration
Swift
public var damping: Double { get set }
-
The minimum distance from the target value (for each component) that the current value can be in order to enter a converged (settled) state.
Declaration
Swift
public var threshold: Double { get set }