LivePanels.Canvas.Viewport (livepanels v0.1.0)

Copy Markdown View Source

Viewport command helpers.

Summary

Types

First argument accepted by viewport command helpers.

Functions

Builds a viewport anchor from explicit world-space bounds.

Requests a viewport fit and returns the command result.

Requests a viewport fit for a selection, visible items, bounds, or graph target.

Requests a viewport fit and returns the command result.

Requests a viewport fit around the given item ids.

Builds a viewport anchor that fits the given item ids.

Moves the viewport to a named anchor and returns the command result.

Moves the current participant's viewport to a named anchor.

Broadcasts a named anchor and returns the command result.

Broadcasts a named anchor as the suggested viewport for all participants.

Stores or replaces a named viewport anchor and returns the command result.

Stores or replaces a named viewport anchor through the canvas command path.

Replaces the active viewport sequence and returns the command result.

Replaces the active viewport sequence with the given anchor names.

Removes a named viewport anchor and returns the command result.

Removes a named viewport anchor and prunes it from the active sequence.

Steps to the next anchor and returns the command result.

Steps the current participant to the next anchor in the active sequence.

Steps to the previous anchor and returns the command result.

Steps the current participant to the previous anchor in the active sequence.

Types

anchor()

@type anchor() :: %{
  :name => String.t(),
  :label => String.t() | nil,
  :x => number(),
  :y => number(),
  :zoom => number(),
  optional(:item_ids) => [String.t()]
}

bounds()

@type bounds() :: %{
  left: number(),
  top: number(),
  width: number(),
  height: number(),
  right: number(),
  bottom: number()
}

command_result()

@type command_result() :: LivePanels.Canvas.Command.result()

socket()

@type socket() :: Phoenix.LiveView.Socket.t()

target()

@type target() :: LivePanels.Canvas.command_target()

First argument accepted by viewport command helpers.

Pass a LiveView socket for a standalone command, or a LivePanels.Canvas.Transaction context inside LivePanels.Canvas.transaction/2.

Functions

anchor_for_bounds(name, bounds, opts \\ [])

@spec anchor_for_bounds(String.t() | atom(), bounds(), keyword()) :: anchor() | nil

Builds a viewport anchor from explicit world-space bounds.

fit(target, fit_target)

@spec fit(target(), term()) :: command_result()

Requests a viewport fit and returns the command result.

fit!(target, fit_target)

@spec fit!(target(), term()) :: target()

Requests a viewport fit for a selection, visible items, bounds, or graph target.

fit_items(target, item_ids)

@spec fit_items(target(), [String.t()] | MapSet.t()) :: command_result()

Requests a viewport fit and returns the command result.

fit_items!(target, item_ids)

@spec fit_items!(target(), [String.t()] | MapSet.t()) :: target()

Requests a viewport fit around the given item ids.

fit_to_items_anchor(source, name, item_ids, opts \\ [])

@spec fit_to_items_anchor(
  map(),
  String.t() | atom(),
  [String.t()] | MapSet.t(),
  keyword()
) ::
  anchor() | nil

Builds a viewport anchor that fits the given item ids.

goto_anchor(target, name)

@spec goto_anchor(target(), String.t() | atom()) :: command_result()

Moves the viewport to a named anchor and returns the command result.

goto_anchor!(target, name)

@spec goto_anchor!(target(), String.t() | atom()) :: target()

Moves the current participant's viewport to a named anchor.

present_anchor(target, name)

@spec present_anchor(target(), String.t() | atom()) :: command_result()

Broadcasts a named anchor and returns the command result.

present_anchor!(target, name)

@spec present_anchor!(target(), String.t() | atom()) :: target()

Broadcasts a named anchor as the suggested viewport for all participants.

put_anchor(target, anchor)

@spec put_anchor(target(), anchor()) :: command_result()

Stores or replaces a named viewport anchor and returns the command result.

put_anchor!(target, anchor)

@spec put_anchor!(target(), anchor()) :: target()

Stores or replaces a named viewport anchor through the canvas command path.

put_sequence(target, sequence)

@spec put_sequence(target(), [String.t() | atom()]) :: command_result()

Replaces the active viewport sequence and returns the command result.

put_sequence!(target, sequence)

@spec put_sequence!(target(), [String.t() | atom()]) :: target()

Replaces the active viewport sequence with the given anchor names.

remove_anchor(target, name)

@spec remove_anchor(target(), String.t() | atom()) :: command_result()

Removes a named viewport anchor and returns the command result.

remove_anchor!(target, name)

@spec remove_anchor!(target(), String.t() | atom()) :: target()

Removes a named viewport anchor and prunes it from the active sequence.

step_next(target)

@spec step_next(target()) :: command_result()

Steps to the next anchor and returns the command result.

step_next!(target)

@spec step_next!(target()) :: target()

Steps the current participant to the next anchor in the active sequence.

step_prev(target)

@spec step_prev(target()) :: command_result()

Steps to the previous anchor and returns the command result.

step_prev!(target)

@spec step_prev!(target()) :: target()

Steps the current participant to the previous anchor in the active sequence.