Toddy.Iced.Widget.Sensor (Toddy v0.3.0)

Copy Markdown View Source

Sensor -- detects visibility and size changes on child content.

Props

  • delay (non_neg_integer) -- delay in milliseconds before emitting events.
  • anticipate (number) -- distance in pixels to anticipate visibility (triggers events before the widget is fully in view).
  • a11y (map) -- accessibility overrides. See Toddy.Iced.A11y.

Events

  • %Sensor{type: :resize, id: id, width: w, height: h} -- emitted on resize.
  • %Sensor{type: :resize, id: "id:show", width: w, height: h} -- emitted when child becomes visible.
  • %Widget{type: :click, id: "id:hide"} -- emitted when child becomes hidden.

Summary

Functions

Sets accessibility annotations.

Sets the anticipation distance in pixels.

Converts this sensor struct to a ui_node() map via the Toddy.Iced.Widget protocol.

Sets the sensor delay in milliseconds.

Appends multiple children to the sensor.

Creates a new sensor struct with optional keyword opts.

Appends a child to the sensor.

Applies keyword options to an existing sensor struct.

Types

option()

@type option() ::
  {:delay, non_neg_integer()}
  | {:anticipate, number()}
  | {:a11y, Toddy.Iced.A11y.t()}

t()

@type t() :: %Toddy.Iced.Widget.Sensor{
  a11y: Toddy.Iced.A11y.t() | nil,
  anticipate: number() | nil,
  children: [Toddy.Iced.ui_node() | struct()],
  delay: non_neg_integer() | nil,
  id: String.t()
}

Functions

a11y(sensor, a11y)

@spec a11y(sensor :: t(), a11y :: Toddy.Iced.A11y.t()) :: t()

Sets accessibility annotations.

anticipate(sensor, anticipate)

@spec anticipate(sensor :: t(), anticipate :: number()) :: t()

Sets the anticipation distance in pixels.

build(sensor)

@spec build(sensor :: t()) :: Toddy.Iced.ui_node()

Converts this sensor struct to a ui_node() map via the Toddy.Iced.Widget protocol.

delay(sensor, delay)

@spec delay(sensor :: t(), delay :: non_neg_integer()) :: t()

Sets the sensor delay in milliseconds.

extend(sensor, children)

@spec extend(sensor :: t(), children :: [Toddy.Iced.ui_node() | struct()]) :: t()

Appends multiple children to the sensor.

new(id, opts \\ [])

@spec new(id :: String.t(), opts :: [option()]) :: t()

Creates a new sensor struct with optional keyword opts.

push(sensor, child)

@spec push(sensor :: t(), child :: Toddy.Iced.ui_node() | struct()) :: t()

Appends a child to the sensor.

with_options(sensor, opts)

@spec with_options(sensor :: t(), opts :: [option()]) :: t()

Applies keyword options to an existing sensor struct.