Animation Helpers

  • Instances of Animatable wrap, and manage animated change to, a value conforming to VectorConvertible.

    Using this class to represent a value is often cleaner than setting up and managing animations independently, as Animatable conveniently channels all changes to the value into the changed event. For example:

    class Foo {
      let size: Animatable<CGSize>
    
      (...)
    
      init() {
        size.changed.observe { [weak self] (val) in
          self?.doSomethingWithSize(val)
        }
      }
    }
    
    let f = Foo()
    f.size.animateTo(CGSize(width: 200.0, height: 200.0))
    
    See more

    Declaration

    Swift

    public final class Animatable<Value: VectorConvertible>
  • Runs an animation until the animations finishes, or until cancel() is called.

    The Animator class is one-shot: It runs the animation precisely one time.

    It starts in the Pending state. From here either:

    • It enters the running state. This occurs if start() is called.
    • It is cancelled. This occurs if cancel() is called, and causes the animator to enter the Completed state, with a result of Cancelled.

    After entering the Running state, the started event is fired. The animation then updates on every frame, triggering the changed event each time, until either:

    • The animation finishes on its own, after which the animator enters the Completed state, with a result of Finished.
    • cancel() is called, after which the animator enters the Completed state, with a result of Cancelled.

    When the animator enters the Completed state, it triggers either the cancelled or finished event, depending on the result. After entering the Completed state, the animator is finished and no further state changes can occur.

    See more

    Declaration

    Swift

    public final class Animator<A: AnimationType>
  • The possible result cases of an animator.

    See more

    Declaration

    Swift

    public enum AnimatorResult
  • The state of an Animator instance.

    See more

    Declaration

    Swift

    public enum AnimatorState: Equatable