summaryrefslogtreecommitdiff
path: root/elements/input.ml
blob: 6ae9aa821ccacc08ff2dbfa273d853ebf2ce16e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
open Brr
open Brr_note
open Note

(** Create a slider element, and a signal with the value *)
let slider
  : at:Brr.At.t list -> Brr.El.t * float S.t

  = fun ~at ->
    let slider =
      El.input ~at () in

    let init_value = (Jstr.to_float (El.prop El.Prop.value slider)) in

    let event =
      Evr.on_el
        Ev.input (fun _ ->
            let raw_value = El.prop El.Prop.value slider in
            Jstr.to_float raw_value)
        slider
      |> S.hold init_value
    in
    slider, event