Skip to content

Commit 92d79d9

Browse files
vouillonsmorimoto
authored andcommitted
Scroll positions are now floats
Adapt to Dom_html API change (ocsigen/js_of_ocaml#1747).
1 parent d0fdd29 commit 92d79d9

File tree

4 files changed

+23
-23
lines changed

4 files changed

+23
-23
lines changed

dune-project

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,13 @@ The client-side code is compiled to JS using Ocsigen Js_of_ocaml or to Wasm usin
2626
ocamlfind
2727
ppx_deriving
2828
(ppxlib (>= 0.15))
29-
(js_of_ocaml-compiler (and (>= 5.5) (< 6.0)))
30-
(js_of_ocaml (>= 5.5))
31-
(js_of_ocaml-lwt (>= 5.5))
29+
(js_of_ocaml-compiler (>= 6.0))
30+
(js_of_ocaml (>= 6.0))
31+
(js_of_ocaml-lwt (>= 6.0))
3232
(js_of_ocaml-ocamlbuild :build)
33-
(js_of_ocaml-ppx (>= 5.5))
34-
(js_of_ocaml-ppx_deriving_json (>= 5.5))
35-
(js_of_ocaml-tyxml (>= 5.5))
33+
(js_of_ocaml-ppx (>= 6.0))
34+
(js_of_ocaml-ppx_deriving_json (>= 6.0))
35+
(js_of_ocaml-tyxml (>= 6.0))
3636
lwt_log
3737
(tyxml (and (>= 4.6) (< 4.7)))
3838
(ocsigenserver (and (>= 6.0) (< 7.0)))

eliom.opam

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,13 @@ depends: [
2222
"ocamlfind"
2323
"ppx_deriving"
2424
"ppxlib" {>= "0.15"}
25-
"js_of_ocaml-compiler" {>= "5.5" & < "6.0"}
26-
"js_of_ocaml" {>= "5.5"}
27-
"js_of_ocaml-lwt" {>= "5.5"}
25+
"js_of_ocaml-compiler" {>= "6.0"}
26+
"js_of_ocaml" {>= "6.0"}
27+
"js_of_ocaml-lwt" {>= "6.0"}
2828
"js_of_ocaml-ocamlbuild" {build}
29-
"js_of_ocaml-ppx" {>= "5.5"}
30-
"js_of_ocaml-ppx_deriving_json" {>= "5.5"}
31-
"js_of_ocaml-tyxml" {>= "5.5"}
29+
"js_of_ocaml-ppx" {>= "6.0"}
30+
"js_of_ocaml-ppx_deriving_json" {>= "6.0"}
31+
"js_of_ocaml-tyxml" {>= "6.0"}
3232
"lwt_log"
3333
"tyxml" {>= "4.6" & < "4.7"}
3434
"ocsigenserver" {>= "6.0" & < "7.0"}

src/lib/client/eliommod_dom.ml

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -687,18 +687,18 @@ let preload_css (doc : Dom_html.element Js.t) =
687687
[@@@warning "-39"]
688688

689689
type position =
690-
{html_top : int; html_left : int; body_top : int; body_left : int}
690+
{html_top : float; html_left : float; body_top : float; body_left : float}
691691
[@@deriving json]
692692

693693
[@@@warning "+39"]
694694

695-
let top_position = {html_top = 0; html_left = 0; body_top = 0; body_left = 0}
695+
let top_position = {html_top = 0.; html_left = 0.; body_top = 0.; body_left = 0.}
696696

697697
let createDocumentScroll () =
698-
{ html_top = Dom_html.document##.documentElement##.scrollTop
699-
; html_left = Dom_html.document##.documentElement##.scrollLeft
700-
; body_top = Dom_html.document##.body##.scrollTop
701-
; body_left = Dom_html.document##.body##.scrollLeft }
698+
{ html_top = Js.to_float Dom_html.document##.documentElement##.scrollTop
699+
; html_left = Js.to_float Dom_html.document##.documentElement##.scrollLeft
700+
; body_top = Js.to_float Dom_html.document##.body##.scrollTop
701+
; body_left = Js.to_float Dom_html.document##.body##.scrollLeft }
702702

703703
(* With firefox, the scroll position is restored before to fire the
704704
popstate event. We maintain our own position. *)
@@ -719,10 +719,10 @@ let _ =
719719
let getDocumentScroll () = !current_position
720720

721721
let setDocumentScroll pos =
722-
Dom_html.document##.documentElement##.scrollTop := pos.html_top;
723-
Dom_html.document##.documentElement##.scrollLeft := pos.html_left;
724-
Dom_html.document##.body##.scrollTop := pos.body_top;
725-
Dom_html.document##.body##.scrollLeft := pos.body_left;
722+
Dom_html.document##.documentElement##.scrollTop := Js.float pos.html_top;
723+
Dom_html.document##.documentElement##.scrollLeft := Js.float pos.html_left;
724+
Dom_html.document##.body##.scrollTop := Js.float pos.body_top;
725+
Dom_html.document##.body##.scrollLeft := Js.float pos.body_left;
726726
current_position := pos
727727

728728
(* UGLY HACK for Opera bug: Opera seem does not always take into

src/lib/client/eliommod_dom.mli

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ val iter_attrList :
8686
(** Window scrolling. *)
8787

8888
type position =
89-
{html_top : int; html_left : int; body_top : int; body_left : int}
89+
{html_top : float; html_left : float; body_top : float; body_left : float}
9090
[@@deriving json]
9191

9292
val top_position : position

0 commit comments

Comments
 (0)