Dala.Media.Animation (dala v0.3.2)

Copy Markdown View Source

Frame-clock driven animation system.

Animations are driven by the frame clock, not by setInterval. This ensures smooth, jank-free animations that are synchronized with the render pipeline.

Architecture:

FrameClock  AnimationSystem  SceneGraph Update

Example

# Animate a node's opacity from 0 to 1 over 500ms
Dala.Media.Animation.animate(scene, node_id, :opacity, %{
  from: 0.0,
  to: 1.0,
  duration_ms: 500,
  easing: :ease_in_out
})

# Animate position
Dala.Media.Animation.animate(scene, node_id, :position, %{
  from: {0, 0},
  to: {100, 200},
  duration_ms: 1000,
  easing: :spring
})

Summary

Functions

Animate a property on a scene node.

Cancel an animation.

Cancel all animations for a node.

Returns a specification to start this module under a supervisor.

Start the animation system, linked to a clock.

Types

anim_ref()

@type anim_ref() :: pid()

easing()

@type easing() :: :linear | :ease_in | :ease_out | :ease_in_out | :spring | :bounce

Functions

animate(pid, node_id, property, opts)

@spec animate(anim_ref(), reference(), atom(), map()) ::
  {:ok, reference()} | {:error, term()}

Animate a property on a scene node.

cancel(pid, anim_id)

@spec cancel(anim_ref(), reference()) :: :ok

Cancel an animation.

cancel_all(pid, node_id)

@spec cancel_all(anim_ref(), reference()) :: :ok

Cancel all animations for a node.

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

start_link(opts \\ [])

@spec start_link(keyword()) :: GenServer.on_start()

Start the animation system, linked to a clock.