If you're tracking a number of timelines in your model, you may decide to use a Watching to simplify adding new timelines.
When new messages come in, we then need to update our model. This looks something like this:
type Msg
= Tick Time.Posix
update msg model =
case msg of
Tick newTime ->
( Animator.update newTime animator model
, Cmd.none
)And voilà, we can begin animating!
Note — To animate more things, all you need to do is add a new with to your Animator.
Convert an Animator to a subscription.
This is where the animator will decide if a running animation needs another frame or not.
subscriptions model =
Animator.toSubscription Tick model animator
An
Animatorknows how to read and write all theTimelineswithin yourModel.Here's an animator from the Checkbox.elm example,
Notice you could add any number of timelines to this animator:
Note — You likely only need one animator for a given project.
Note 2 — Once we have an
Animator Model, we have two more steps in order to set things up: