GenServer that manages timed property animations for widgets.
Animations interpolate numeric values, RGB color tuples, or discrete values
between a start and end state over a specified duration. The server ticks at
60 fps, applies easing, and sends {:apply_animation, widget_id, property, value}
messages to the app loop for each active animation.
Supported easing atoms: :linear, :ease, :ease_in, :ease_out,
:ease_in_out, :ease_in_quad, :ease_out_quad, :ease_in_out_quad,
:ease_in_cubic, :ease_out_cubic, :ease_in_out_cubic,
:ease_in_elastic, :ease_out_elastic, :ease_out_bounce,
:ease_in_bounce, :ease_in_out_bounce, :ease_in_back, :ease_out_back.
Summary
Functions
Animate property of the widget with id widget_id towards end_value.
Returns a specification to start this module under a supervisor.
The animations currently running for widget_id, or [] if it has none.
The value property has reached in the animation running for widget_id.
Start the animation server, registered under this module's name.
Stop the animation started by the call that returned animation_id.
Stop every running animation for widget_id, as stop/1 does for one. Asynchronous.
Advance every running animation by one frame immediately.
Types
Functions
Animate property of the widget with id widget_id towards end_value.
The starting value is the widget's current value for that property. Numbers are
interpolated numerically, {r, g, b} tuples channel by channel, and any other
value switches at the end of the duration.
Options:
:duration— milliseconds the animation runs for, default300:easing— one of the easing atoms listed in the module documentation, default:ease_out:on_complete— zero-argument function called once the animation finishes; not called when the animation is stopped early
Returns a reference identifying the animation, which stop/1 takes. Starting a
second animation for the same widget and property leaves the first running.
Returns a specification to start this module under a supervisor.
See Supervisor.
The animations currently running for widget_id, or [] if it has none.
The value property has reached in the animation running for widget_id.
Returns {:ok, value}, or :none when no animation is running for that widget
and property.
@spec start_link(keyword()) :: GenServer.on_start()
Start the animation server, registered under this module's name.
One runs per node, started by the Drafter application supervisor. opts are accepted and
discarded; the tick rate is fixed at 60 fps.
@spec stop(reference()) :: :ok
Stop the animation started by the call that returned animation_id.
The property keeps whatever value it had reached and :on_complete is not run.
An unknown reference is ignored. Asynchronous.
@spec stop_all(atom()) :: :ok
Stop every running animation for widget_id, as stop/1 does for one. Asynchronous.
@spec tick() :: :ok
Advance every running animation by one frame immediately.
The server already ticks itself at 60 fps; calling this only brings the next frame forward. Asynchronous.