Animation Helpers
-
Instances of
Animatable
wrap, and manage animated change to, a value conforming toVectorConvertible
.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 thechanged
event. For example:
See moreclass 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))
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 ofCancelled
.
After entering the
Running
state, thestarted
event is fired. The animation then updates on every frame, triggering thechanged
event each time, until either:- The animation finishes on its own, after which the animator enters the
Completed
state, with a result ofFinished
. cancel()
is called, after which the animator enters theCompleted
state, with a result ofCancelled
.
When the animator enters the
See moreCompleted
state, it triggers either thecancelled
orfinished
event, depending on the result. After entering theCompleted
state, the animator is finished and no further state changes can occur.Declaration
Swift
public final class Animator<A: AnimationType>
-
The possible result cases of an animator.
See moreDeclaration
Swift
public enum AnimatorResult
-
Declaration
Swift
public enum AnimatorState: Equatable
-
Declaration
Swift
public final class AnimatorContext