brazier/event

Values

pub fn checked() -> decode.Decoder(Bool)

event.target.checked.

pub fn debounce(
  event: attribute.Attribute(msg),
  ms: Int,
) -> attribute.Attribute(msg)

Wait until the event has not fired for ms milliseconds, then dispatch the latest one.

pub fn form_data() -> decode.Decoder(List(#(String, String)))

The submitted form’s string fields, in document order. File fields are left out.

pub fn key() -> decode.Decoder(String)

event.key.

pub fn mouse_position() -> decode.Decoder(#(Float, Float))

#(event.offsetX, event.offsetY), relative to the target element.

pub fn on(
  name: String,
  handler: decode.Decoder(msg),
) -> attribute.Attribute(msg)

Listen for the DOM event name and decode it into a message.

name is the DOM event type without the on prefix, e.g. "click" or "pointermove".

pub fn on_blur(msg: msg) -> attribute.Attribute(msg)
pub fn on_change(
  msg: fn(String) -> msg,
) -> attribute.Attribute(msg)

The input’s value on change (commit, e.g. blur or select).

pub fn on_check(msg: fn(Bool) -> msg) -> attribute.Attribute(msg)

A checkbox’s checked state on change.

pub fn on_click(msg: msg) -> attribute.Attribute(msg)
pub fn on_double_click(msg: msg) -> attribute.Attribute(msg)
pub fn on_drag_end(msg: msg) -> attribute.Attribute(msg)
pub fn on_drag_over(msg: msg) -> attribute.Attribute(msg)

dragover. The default is prevented, which is what makes an element a drop target.

pub fn on_drag_start(msg: msg) -> attribute.Attribute(msg)
pub fn on_drop(msg: msg) -> attribute.Attribute(msg)

drop. The browser’s default handling (opening a dropped link or file) is prevented.

pub fn on_focus(msg: msg) -> attribute.Attribute(msg)
pub fn on_input(
  msg: fn(String) -> msg,
) -> attribute.Attribute(msg)

The input’s current value on every input event.

pub fn on_keydown(
  msg: fn(String) -> msg,
) -> attribute.Attribute(msg)

event.key on keydown.

pub fn on_keypress(
  msg: fn(String) -> msg,
) -> attribute.Attribute(msg)

event.key on keypress.

pub fn on_keyup(
  msg: fn(String) -> msg,
) -> attribute.Attribute(msg)

event.key on keyup.

pub fn on_mouse_down(msg: msg) -> attribute.Attribute(msg)
pub fn on_mouse_enter(msg: msg) -> attribute.Attribute(msg)
pub fn on_mouse_leave(msg: msg) -> attribute.Attribute(msg)
pub fn on_mouse_out(msg: msg) -> attribute.Attribute(msg)
pub fn on_mouse_over(msg: msg) -> attribute.Attribute(msg)
pub fn on_mouse_up(msg: msg) -> attribute.Attribute(msg)
pub fn on_submit(
  msg: fn(List(#(String, String))) -> msg,
) -> attribute.Attribute(msg)

The form’s string fields on submit. The browser’s default submission is prevented.

pub fn prevent_default(
  event: attribute.Attribute(msg),
) -> attribute.Attribute(msg)

Call preventDefault on the event before decoding it.

pub fn stop_propagation(
  event: attribute.Attribute(msg),
) -> attribute.Attribute(msg)

Call stopPropagation on the event: listeners on ancestors do not run.

pub fn throttle(
  event: attribute.Attribute(msg),
  ms: Int,
) -> attribute.Attribute(msg)

Dispatch at most one event every ms milliseconds (the first one in each window).

pub fn value() -> decode.Decoder(String)

event.target.value.

✨ Search Document