Skip to content

Commit 83ee000

Browse files
vouillonhhugo
authored andcommitted

File tree

3 files changed

+19
-14
lines changed

3 files changed

+19
-14
lines changed

lib/js_of_ocaml/dom_html.ml

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -727,9 +727,9 @@ and element = object
727727

728728
method offsetHeight : int readonly_prop
729729

730-
method scrollLeft : int prop
730+
method scrollLeft : number_t prop
731731

732-
method scrollTop : int prop
732+
method scrollTop : number_t prop
733733

734734
method scrollWidth : int prop
735735

@@ -2321,9 +2321,9 @@ class type window = object
23212321

23222322
method blur : unit meth
23232323

2324-
method scroll : int -> int -> unit meth
2324+
method scroll : number_t -> number_t -> unit meth
23252325

2326-
method scrollBy : int -> int -> unit meth
2326+
method scrollBy : number_t -> number_t -> unit meth
23272327

23282328
method sessionStorage : storage t optdef readonly_prop
23292329

@@ -2888,8 +2888,12 @@ let eventRelatedTarget (e : #mouseEvent t) =
28882888
let eventAbsolutePosition' (e : #mouseEvent t) =
28892889
let body = document##.body in
28902890
let html = document##.documentElement in
2891-
( Js.to_float e##.clientX +. Float.of_int (body##.scrollLeft + html##.scrollLeft)
2892-
, Js.to_float e##.clientY +. Float.of_int (body##.scrollTop + html##.scrollTop) )
2891+
( Js.to_float e##.clientX
2892+
+. Js.to_float body##.scrollLeft
2893+
+. Js.to_float html##.scrollLeft
2894+
, Js.to_float e##.clientY
2895+
+. Js.to_float body##.scrollTop
2896+
+. Js.to_float html##.scrollTop )
28932897

28942898
let eventAbsolutePosition (e : #mouseEvent t) =
28952899
Optdef.case
@@ -2911,7 +2915,8 @@ let elementClientPosition (e : #element t) =
29112915
let getDocumentScroll () =
29122916
let body = document##.body in
29132917
let html = document##.documentElement in
2914-
body##.scrollLeft + html##.scrollLeft, body##.scrollTop + html##.scrollTop
2918+
( Js.to_float body##.scrollLeft +. Js.to_float html##.scrollLeft
2919+
, Js.to_float body##.scrollTop +. Js.to_float html##.scrollTop )
29152920

29162921
let buttonPressed (ev : #mouseEvent Js.t) =
29172922
Js.Optdef.case

lib/js_of_ocaml/dom_html.mli

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -740,9 +740,9 @@ and element = object
740740

741741
method offsetHeight : int readonly_prop
742742

743-
method scrollLeft : int prop
743+
method scrollLeft : number_t prop
744744

745-
method scrollTop : int prop
745+
method scrollTop : number_t prop
746746

747747
method scrollWidth : int prop
748748

@@ -2165,9 +2165,9 @@ class type window = object
21652165

21662166
method blur : unit meth
21672167

2168-
method scroll : int -> int -> unit meth
2168+
method scroll : number_t -> number_t -> unit meth
21692169

2170-
method scrollBy : int -> int -> unit meth
2170+
method scrollBy : number_t -> number_t -> unit meth
21712171

21722172
method sessionStorage : storage t optdef readonly_prop
21732173

@@ -2597,7 +2597,7 @@ val eventAbsolutePosition : #mouseEvent t -> float * float
25972597
val elementClientPosition : #element t -> int * int
25982598
(** Position of an element relative to the viewport *)
25992599

2600-
val getDocumentScroll : unit -> int * int
2600+
val getDocumentScroll : unit -> float * float
26012601
(** Viewport top/left position *)
26022602

26032603
(** {2 Key event helper functions} *)

toplevel/examples/lwt_toplevel/toplevel.ml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ let resize ~container ~textbox () =
145145
textbox##.style##.height := Js.string "auto";
146146
textbox##.style##.height
147147
:= Js.string (Printf.sprintf "%dpx" (max 18 textbox##.scrollHeight));
148-
container##.scrollTop := container##.scrollHeight;
148+
container##.scrollTop := Js.float (float container##.scrollHeight);
149149
Lwt.return ()
150150

151151
let setup_printers () =
@@ -376,7 +376,7 @@ let run _ =
376376
JsooTop.execute true ~pp_code:sharp_ppf ~highlight_location caml_ppf content';
377377
resize ~container ~textbox ()
378378
>>= fun () ->
379-
container##.scrollTop := container##.scrollHeight;
379+
container##.scrollTop := Js.float (float container##.scrollHeight);
380380
textbox##focus;
381381
Lwt.return_unit
382382
in

0 commit comments

Comments
 (0)