Animation

public class Animation<T> : AnimationProviding where T : SpringInterpolatable
extension Animation: CustomStringConvertible
  • Declaration

    Swift

    public enum Event
  • id

    A unique identifier for the animation.

    Declaration

    Swift

    public let id: UUID
  • The execution state of the animation (inactive, running, or ended).

    Declaration

    Swift

    public private(set) var state: AnimationState { get set }
  • The spring model that determines the animation’s motion.

    Declaration

    Swift

    public var spring: Spring
  • The current value of the animation. This value will change as the animation executes.

    value needs to be set to a non-nil value before the animation can start.

    Declaration

    Swift

    public var value: T.ValueType?
  • The current target value of the animation.

    You may modify this value while the animation is in-flight to “retarget” to a new target value.

    Declaration

    Swift

    public var target: T.ValueType? { get set }
  • The current velocity of the animation.

    If animating a view’s center or frame with a gesture, you may want to set velocity to the gesture’s final velocity on touch-up.

    Declaration

    Swift

    public var velocity: T.VelocityType
  • The callback block to call when the animation’s value changes as it executes. Use the currentValue to drive your application’s animations.

    Declaration

    Swift

    public var valueChanged: ((_ currentValue: T.ValueType) -> Void)?
  • The completion block to call when the animation either finishes, or “re-targets” to a new target value.

    Declaration

    Swift

    public var completion: ((_ event: Event) -> Void)?
  • The animation’s mode. If set to .nonAnimated, the animation will snap to the target value when run.

    Declaration

    Swift

    public var mode: AnimationMode
  • Whether the values returned in valueChanged should be integralized to the screen’s pixel boundaries. This helps prevent drawing frames between pixels, causing aliasing issues.

    Note: Enabling integralizeValues effectively quantizes value, so don’t use this for values that are supposed to be continuous.

    Declaration

    Swift

    public var integralizeValues: Bool
  • Creates a new animation with a given Spring, and optionally, an initial and target value. While value and target are optional in the initializer, they must be set to non-nil values before the animation can start.

    Declaration

    Swift

    public init(spring: Spring, value: T.ValueType? = nil, target: T.ValueType? = nil)

    Parameters

    spring

    The spring model that determines the animation’s motion.

    value

    The initial, starting value of the animation.

    target

    The target value of the animation.

  • Starts the animation (if not already running) with an optional delay.

    Declaration

    Swift

    public func start(afterDelay delay: TimeInterval = 0)

    Parameters

    delay

    The amount of time (measured in seconds) to wait before starting the animation.

  • Stops the animation at the current value.

    Declaration

    Swift

    public func stop(immediately: Bool = true)
  • How long the animation will take to complete, based off its spring property.

    Note: This is useful for debugging purposes only. Do not use settlingTime to determine the animation’s progress.

    Declaration

    Swift

    public var settlingTime: TimeInterval { get }
  • Declaration

    Swift

    public var description: String { get }