From 9d65e5e6a5bd8666baf0d7d3e0474c721cafc683 Mon Sep 17 00:00:00 2001 From: Sébastien Dailly Date: Mon, 28 Dec 2020 21:17:20 +0100 Subject: Fixed width and angle sliddes --- elements/input.ml | 29 +++++++++++++++++------------ elements/prop.ml | 15 +++++++++++++++ 2 files changed, 32 insertions(+), 12 deletions(-) create mode 100755 elements/prop.ml (limited to 'elements') 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 diff --git a/elements/prop.ml b/elements/prop.ml new file mode 100755 index 0000000..715adec --- /dev/null +++ b/elements/prop.ml @@ -0,0 +1,15 @@ +open Brr + +include El.Prop + +let offsetWidth + : int t + = El.Prop.int (Jstr.v "offsetWidth") + +let offsetHeight + : int t + = El.Prop.int (Jstr.v "offsetHeight") + +let outerHTML + : Jstr.t t + = El.Prop.jstr (Jstr.v "outerHTML") -- cgit v1.2.3