Raxol.Adaptive.LayoutTransition (Raxol v2.3.0)

View Source

Pure functional layout interpolation between two layouts.

Lerps pane positions and sizes. Snaps z_order and hidden lists. Supports linear, ease_in_out, and ease_out easing curves.

Summary

Types

easing()

@type easing() :: :linear | :ease_in_out | :ease_out

layout_spec()

@type layout_spec() :: %{panes: [pane_spec()], focus: atom() | nil, hidden: [atom()]}

pane_spec()

@type pane_spec() :: %{
  id: atom(),
  position: {number(), number()},
  size: {number(), number()},
  z_order: integer()
}

transition()

@type transition() :: %{
  from: layout_spec(),
  to: layout_spec(),
  duration_ms: pos_integer(),
  easing: easing(),
  started_at: integer(),
  progress: float()
}

Functions

cancel(transition)

@spec cancel(transition()) :: layout_spec()

interpolate_layout(from, to, t)

@spec interpolate_layout(layout_spec(), layout_spec(), float()) :: layout_spec()

start(from, to, opts \\ [])

@spec start(layout_spec(), layout_spec(), keyword()) :: transition()

tick(transition, elapsed_ms)

@spec tick(transition(), integer()) ::
  {:in_progress, layout_spec(), transition()} | {:done, layout_spec()}