aboutsummaryrefslogtreecommitdiff
path: root/elements/input.ml
diff options
context:
space:
mode:
Diffstat (limited to 'elements/input.ml')
-rwxr-xr-xelements/input.ml29
1 files changed, 17 insertions, 12 deletions
diff --git a/elements/input.ml b/elements/input.ml
index 790b15d..935f34a 100755
--- a/elements/input.ml
+++ b/elements/input.ml
@@ -3,18 +3,23 @@ open Brr_note
open Note
(** Create a slider element, and a signal with the value *)
-let slider ~at =
- let slider =
- El.input ~at () in
+let slider
+ : at:Brr.At.t list -> Brr.El.t * float S.t
- let event =
- Evr.on_el
- Ev.input (fun _ ->
- let raw_value = El.prop El.Prop.value slider in
- Jstr.to_int raw_value)
- slider
- |> S.hold (Jstr.to_int (El.prop El.Prop.value slider))
- in
- slider, event
+ = 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