Raxol.Animation.DSL (Raxol v2.0.1)

View Source

Declarative animation DSL for composing complex animation sequences.

This module provides a fluent, chainable API for creating sophisticated animations with timing controls, parallel execution, and conditional logic.

Examples

# Simple animation sequence
import Raxol.Animation.DSL

sequence()
|> fade_in(duration: 300)
|> slide_up(distance: 20, duration: 400)
|> scale_bounce(scale: 1.2, duration: 200)
|> execute(element_id)

# Parallel animations
parallel()
|> with_animation(fade_in(duration: 500))
|> with_animation(rotate(degrees: 360, duration: 1000))
|> execute(element_id)

# Conditional animations
sequence()
|> fade_in(duration: 300)
|> when_condition(fn state -> state.user_type == :premium end)
|> sparkle_effect(duration: 1000)
|> end_condition()
|> slide_out(direction: :right, duration: 400)
|> execute(element_id)

# Complex choreographed animation
choreography()
|> stage("entrance",
     sequence()
     |> fade_in(duration: 300)
     |> slide_up(distance: 30, duration: 500, easing: :ease_out_back)
   )
|> stage("highlight",
     parallel()
     |> with_animation(glow_effect(duration: 800))
     |> with_animation(pulse_scale(scale: 1.05, duration: 600))
   )
|> stage("exit",
     sequence()
     |> fade_out(duration: 400)
     |> scale_down(scale: 0.8, duration: 300)
   )
|> execute_choreography(element_id)

Summary

Functions

Creates a new choreography for complex multi-stage animations.

Adds a delay to the sequence.

Ends a conditional block.

Executes the animation sequence for the given element.

Executes a choreography with multiple stages.

Adds a fade in animation to the sequence.

Adds a fade out animation to the sequence.

Adds a glow effect animation.

Loops the sequence infinitely or for a specified number of iterations.

Creates a parallel animation group.

Adds a pulse scale animation.

Repeats the previous animation or sequence.

Adds a rotation animation.

Adds a scale animation to the sequence.

Adds a scale bounce animation.

Adds a scale down animation.

Creates a new animation sequence.

Adds a slide animation to the sequence.

Adds a sparkle effect animation.

Adds a stage to a choreography.

Adds a conditional block to the sequence.

Adds an animation to a parallel group.

Functions

choreography(options \\ %{})

Creates a new choreography for complex multi-stage animations.

delay(sequence, duration)

Adds a delay to the sequence.

end_condition(sequence)

Ends a conditional block.

execute(sequence, element_id, options \\ %{})

Executes the animation sequence for the given element.

execute_choreography(choreo, element_id, options \\ %{})

Executes a choreography with multiple stages.

fade_in(sequence_or_options \\ %{})

Adds a fade in animation to the sequence.

fade_in(sequence, options)

fade_out(sequence_or_options \\ %{})

Adds a fade out animation to the sequence.

fade_out(sequence, options)

glow_effect(sequence_or_options \\ %{})

Adds a glow effect animation.

glow_effect(sequence, options)

loop(sequence, iterations \\ :infinite)

Loops the sequence infinitely or for a specified number of iterations.

parallel(options \\ %{})

Creates a parallel animation group.

pulse_scale(sequence_or_options \\ %{})

Adds a pulse scale animation.

pulse_scale(sequence, options)

repeat(sequence, times)

Repeats the previous animation or sequence.

rotate(sequence_or_options \\ %{})

Adds a rotation animation.

rotate(sequence, options)

scale(sequence_or_options \\ %{})

Adds a scale animation to the sequence.

scale(sequence, options)

scale_bounce(sequence_or_options \\ %{})

Adds a scale bounce animation.

scale_bounce(sequence, options)

scale_down(sequence_or_options \\ %{})

Adds a scale down animation.

scale_down(sequence, options)

sequence(options \\ %{})

Creates a new animation sequence.

slide(sequence_or_options \\ %{})

Adds a slide animation to the sequence.

slide(sequence, options)

slide_down(sequence, options \\ %{})

slide_in(sequence_or_options \\ %{}, options \\ %{})

Adds a slide in animation.

slide_left(sequence, options \\ %{})

slide_out(sequence_or_options \\ %{}, options \\ %{})

Adds a slide out animation.

slide_right(sequence, options \\ %{})

slide_up(sequence, options \\ %{})

sparkle_effect(sequence_or_options \\ %{})

Adds a sparkle effect animation.

sparkle_effect(sequence, options)

stage(choreo, name, sequence)

Adds a stage to a choreography.

when_condition(sequence, condition_fn)

Adds a conditional block to the sequence.

with_animation(parallel_sequence, animation)

Adds an animation to a parallel group.