# `Toddy.Iced.Widget.Sensor`
[🔗](https://github.com/toddy-ui/toddy-elixir/blob/v0.3.0/lib/toddy/iced/widget/sensor.ex#L1)

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.

# `option`

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

# `t`

```elixir
@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()
}
```

# `a11y`

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

Sets accessibility annotations.

# `anticipate`

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

Sets the anticipation distance in pixels.

# `build`

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

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

# `delay`

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

Sets the sensor delay in milliseconds.

# `extend`

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

Appends multiple children to the sensor.

# `new`

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

Creates a new sensor struct with optional keyword opts.

# `push`

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

Appends a child to the sensor.

# `with_options`

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

Applies keyword options to an existing sensor struct.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
