Raxol.Animation.Lifecycle (Raxol v2.0.1)
View SourceManages the lifecycle of animations including starting, stopping, and completion handling.
This module is responsible for:
- Starting animations on elements
- Stopping animations
- Handling animation completion and callbacks
- Managing animation announcements and accessibility
Summary
Functions
Get the current value of an animation for a specific element.
Handle animation completion, including callbacks and notifications.
Start an animation for a specific element.
Stop an animation for a specific element.
Functions
Get the current value of an animation for a specific element.
Parameters
animation_name- The name of the animationelement_id- Identifier for the element
Returns
{:ok, value}- Current animation value{:error, :animation_not_found}- Animation was not found
Handle animation completion, including callbacks and notifications.
This function is called when an animation completes, either naturally or due to being disabled.
Start an animation for a specific element.
Parameters
animation_name- The name of the animation to startelement_id- Identifier for the element being animatedopts- Additional optionsuser_preferences_pid- (Optional) The UserPreferences process pid or name for accessibility announcements
Options
:on_complete- Function to call when animation completes:context- Additional context for the animation
Path Scoping
If the animation's target_path is a property (e.g., [:opacity]), the framework will automatically scope it to the element's state (e.g., [:elements, element_id, :opacity]).
If you provide a fully qualified path, it will be used as-is.
Examples
iex> AnimationFramework.start_animation(:fade_in, "search_button", %{}, user_preferences_pid)
:ok
iex> AnimationFramework.start_animation(:slide_in, "panel", %{on_complete: &handle_complete/1}, user_preferences_pid)
:ok
Stop an animation for a specific element.
Parameters
animation_name- The name of the animation to stopelement_id- Identifier for the element
Returns
:ok- Animation was stopped successfully{:error, :animation_not_found}- Animation was not found